Hi,
I have the following class.
public class Hello
{
int num = 0;
String flower;
public static void main(String args[])
{
num = 10;
flower = new String("Roses");
Hello sb = new Hello();
sb.print();
}
public void print()
{
System.out.println(num + flower);
tryAgain();
}
public void tryAgain()
{
System.out.println(num + flower);
}
}
My question is-
1. I have declared num as a class variable. Will any changes made to it by
a member function automatically alter the valye of num?
2. Hence if some other method like tryAgain tries to access num, what will it print?
3. In order to make num accessible everywhere in the class, although changed in value in a method, what should I do?
Thanks.