aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes  GREAT ANOMOly and border layout? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark " GREAT ANOMOly and border layout?" Watch " GREAT ANOMOly and border layout?" New topic
Author

GREAT ANOMOly and border layout?

sunilkumar ssuparasmul
Ranch Hand

Joined: Dec 13, 2000
Posts: 142

The BorderLayout manager only allows a single component to be added to each sector.
what does it mean can somebody explain?
int Integer=10;
int Math=20;
above r valid . how come?
How can we define a class as a name of the variable?
But this is not valid Y?
int System=10;
Can somebody plz explain the anomoly behind it.
Is it that i can define all Final Classes as variables ?
I am confused

------------------
"Winners don't do different things
They do things differently"


"Winners don't do different things<br /> They do things differently"
deekasha gunwant
Ranch Hand

Joined: May 06, 2000
Posts: 396
hi sunil,
------------------------------------------------------
The BorderLayout manager only allows a single component to be added to each sector
bordear layout divides thae container in five areas.
- Eas
- West
- North
- South
- Center
and It allows one and only one element in each of these sections.
if u try to add more than one component in any of them then only the last component will be visible.
hope this clears your doubt.
-----------------------------------------------------
nt Integer=10;
int Math=20;
above r valid . how come?
How can we define a class as a name of the variable?

again sunil the onle restriction java put for variable name declration is that they should not be same as reserved words.
now System is a reserved word in java. but other class names such as Math/Integer/String are not reserved.so u can use them as variable names in your program. although it may not be a good thing to do.

---------------------------------------------
if not clear do post the doubts..
regards
deekasha
Zheng Huang
Ranch Hand

Joined: Dec 20, 2000
Posts: 49
System is not a reserved word. The following will compile.
public class TestApp {
public static void main(String argv[]) {
int System=10;
int Integer=10;
int Math=20;
}
}
However, You can not used the those variables with the same name classes (in this case, they are System, Integer and Math). The code below will not compile.
public class TestApp {
public static void main(String argv[]) {
int System=10;
int Integer=10;
int i = Integer.MAX_VALUE;
int Math=20;
}
}
sunilkumar ssuparasmul
Ranch Hand

Joined: Dec 13, 2000
Posts: 142
Thanks Deekasha and Zheng ,
I could remember now what can be used as a variable. and also as Zheng said u can define it but u cannot use it in the same context
For eg:
int System=10;//will compile and run 1
But
int System=10;// 2
System.out.println(System);//will not compile 2
But y the first one compiles ?can u throw light on this
Thanks in advance,
sunil.s
------------------
"Winners don't do different things
They do things differently"
deekasha gunwant
Ranch Hand

Joined: May 06, 2000
Posts: 396
hi sunil ,
and thanks zheng, for pointing out that System is not a keyword.I just missed the fact that all reserved words in java are in small case.
Now Sunil once you declare System as a variable name in your program then from that point onwards till the scope of the var goes word 'System' is considered as int var not as a java class and hence u can not use System.out ..
but outside your variable's scope u can use System.out...


run the above program. as it is.and then uncomment the commented line and run again.
hope u'll understand the concept.
regards
deekasha
[This message has been edited by deekasha gunwant (edited January 16, 2001).]
sunilkumar ssuparasmul
Ranch Hand

Joined: Dec 13, 2000
Posts: 142
Thanks Deekasha

------------------
"Winners don't do different things
They do things differently"
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: GREAT ANOMOly and border layout?