package Student;
public class Example
{
int i = 10;//instance variable which is created under class
void age()// age is method here
{
int j=11;// local variable which is created under method
}
public static void main(String[] args) {
Example ex = new Example();//Creating the object
System.out.println("Display the valule" ex.age());
ex.age();
}
}
我無法打印第j值的價值..打印局部變量
Java教程:從方法返回一個值(https://docs.oracle.com/javase/tutorial/java/javaOO/returnvalue.html) – khelwood
你需要從返回''j' age'。另外,你需要說出你在問什麼時遇到了什麼問題。這是一個非常模糊的問題 – Carcigenicate