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 your platform?s default character encoding and how to know this?
What are the legal operands of the instanceof operator?
What about method local inner classes or local inner classes in java?
explain the concept of virtual method invocation in polymorphism in detail?
What are the two ways in which thread can be created?
What is an empty class? What functionality does it offer in Java?
How to find the largest value from the given array.
What is the difference between jdk, jre, and jvm?
Which container method is used to cause a container to be laid out and redisplayed in java programming?
Which variable is the independent variable?
Is singleton class thread safe?
What is primitive array?
What is the difference between iterator and list iterator?
What’s meant by anonymous class?
What is ph and buffers?