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
What is java reflection?
How to create a custom exception?
What about interrupt() method of thread class ?
What defines function?
What does the “static” keyword mean?
Which package is used for pattern matching with regular expressions?
Explain the difference between the public, private, final, protected, and default modifiers?
Write an algorithm for quick sort?
How do you compare characters in java?
Can this keyword be used to refer static members?
What is an immutable class?
What is static data type in java?
What is indexof?
Why main() method is public, static and void in java ?
What does flagged out mean?