saloni jhanwar

Ranch Hand
+ Follow
since Feb 09, 2012
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by saloni jhanwar

Panagiotis Kalogeropoulos wrote:I thought your question was about why to use iterators since we have the for loop (scratching my head......). Maybe the expression "pros and cons" that I used was not the best, but in that link you can see why and when you should use the for loop or an iterator. I don't know if that still answers your question (scratching my head again....).



If you really know that your that link has my answer and you are sure then why don't you post that answer of that document ?
12 years ago
Hi folk
My question is that if i can iterate an ArrayList using for loop then what does iterator() make difference here ?
12 years ago

Manoj Kumar Jain wrote:This code will not compile, not because the array is uninitialized. Array elements are initialized with their default value that is 0 for integers.
This will fail because there is a local variable size that is not initialized before using and that is line no. 5



I know already that but i think elements arr[0]-[9] are also local variables.
12 years ago


I thought it will fail to compile because array is uninitialized.
12 years ago
Thanks everyone
12 years ago
12 years ago

Campbell Ritchie wrote:How old is your book? Have a look through all those classes for valueOf methods, and I think you will find more than there are in your table.



My book is new, i have K&B 6,and that snap was from k&b 6.
12 years ago
Thanks Henry for new logic.
12 years ago

Matthew Brown wrote:You're trying to cast am Integer to a Byte. They aren't compatible, they're on different inheritance branches. That would only make sense if Byte was a subclass of Integer.



Then i were expecting ClassCastException.
12 years ago

F:\Wrapper classes>javac Example.java
Example.java:11: error: inconvertible types
byte b2=(Byte)f2;

Why inconvertible ? After casting it should be convertible
12 years ago
I got confuse becaude even K&B showing no parseXxx method for Boolean and Character class.

12 years ago

Matthew Brown wrote:What makes you think the method doesn't exist? It's there in the documentation.


http://docs.oracle.com/javase/1.4.2/docs/api/java/lang/Boolean.html
12 years ago
Whereas I know there are only six parseXxx() methods for numeric type of primitives.
There is no method for Boolean class then how thiscode is working and printing even true

Output:true
12 years ago