Answer Posted / satish
Direct global variables are not possible like
int i=0;
class{
....
....
}
But other way is create a class with static variables and
you can use it wherever needed.
class Global{
public static int i;
public static String s="";
}
class SomeClass{
public static void main(String args[]){
Global.i=23;
Global.s="Whats up"
}
}
Is This Answer Correct ? | 6 Yes | 2 No |
Post New Answer View All Answers
Why are global variables used?
How can an object be unreferenced?
Can we have two main methods in a java class?
What is methods in java?
What is boolean keyword in java?
What is a java lambda expression?
How is Object Oriented Programming different from Procedure Oriented Programming?
How many tetrahedral voids are there in bcc?
What is navigable map in java?
When is the finalize() called? What is the purpose of finalization?
Can we increase array size dynamically in java?
What is a arraylist in java?
Explain the importance of finalize() method.
How is a structure different from array ?
What is a byte string?