Payel Bera

+ Follow
since Jan 28, 2010
Merit badge: grant badges
For More
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Payel Bera

Hi Campbell, Thank you for your clarification!!

1) If no public class, then the name of the java file can be the same as any of the non public class or any other name like,,, please let me know if my understanding is correct.
2) if we have class sample in file then the code inside will execute whenn we run,,, please let me know if my understanding is correct. Thanks in advance,.
14 years ago
1) If we have one or more than one non public classes in a java file then what will a legal name of that file?--->Can it be any name apart from the names of the classes in the file or any of the class’ name’s?
2)Why is it that the class sample in file , is getting compiled but it is throwing exception at runtime?[java.lang.noclassdeffound error]
14 years ago
Thank you Tim and Abimaran for your prompt responses. Highly appreciate your explanations.

Rob Prime wrote:new Integer(xxx) will always create a new object, so it will never be equal (==) to any other object.
Although Integer.valueOf(int) does use a pool, Integer.valueOf(String) (the one you are using) will also create new objects each time.

Thank you ROB for your prompt reply. Highly appreciate your explanation.
14 years ago

Ankit Garg wrote:Payel please start a new topic for your problem by clicking .

Also when you post the code in the new topic, please Use Code Tags...

Hi ankit,

The topic was a continuation of the same query so does not need to be included as a separate topic/ new topic.
Regarding code tag will keep that in mind in the next post, for sure.
BTW can you/ anyone else provide the explanation, thanks
Hi Rob Prime,

I still have a query on this topic :-

Below is my code and the output, kindly comment on the output

public class MyTest {

public static void main(String args[])
Integer i1 = new Integer (1000);
Integer i2 = new Integer (1000);
Integer i3 = new Integer (10);
Integer i4 = new Integer (10);
Integer i5 = Integer.valueOf("900");
Integer i6 = Integer.valueOf("900");
Integer i7 = Integer.valueOf("90");
Integer i8 = Integer.valueOf("90");

if(i1 == i2) System.out.println("i1 == i2");
else System.out.println("i1 != i2");
if(i3 == i4) System.out.println("i3 == i4");
else System.out.println("i3 != i4");
if(i5 == i6) System.out.println("i5 == i6");
else System.out.println("i5 != i6");
if(i7 == i8) System.out.println("i7 == i8");
else System.out.println("i7 != i8");



i1 != i2
i3 != i4
i5 != i6
i7 != i8
14 years ago
Hi ankit,

thanks for your explanation.
I hope I can now safely infer that only letters (Aa to Zz), (0-9) and $ and _ are valid characters in a Java identifier.
There are no more currency character and separating character apart from $ and _.
Please correct me if I am wrong..
Thanks in advance.

Hi Henry,

Thanks for explaining this. Please let me know that apart from "$" which are the other currency character that can be used as a valid identifier.
Also apart from "_" which are the other separating character that can be used as a valid identifier


suresh mandalapu wrote:give suitable reason please......

In K& S book it is mentioned that the "Identifiers must start with a letter, a currency character ($), or a connecting
character such as the underscore ( _ )." I think "#" is the currency character for pound.Then why is "$" accepted as a valid currency character and not "#"