datta Nadgir

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

Recent posts by datta Nadgir

HI all,

I'm a Java Learner, My instructor said me to look at java source code of class (thread class) that is present in JDK, Its really good and I understand it clearly,, but he also suggests me to look at API. Which would be the best practice? to go for API or source code of class ?? THANKS IN ADVANCE
9 years ago
step1: increment the value of first num(lower limit) and
write a for loop that starts from incremented first value and <last number, write the code that finds the sum,

if even number ;
check the first number if its even or odd,
if odd, then add 1 and iterate the loop for every2 elements;
write code that finds the sum;
similalry for odd numbers too;
9 years ago
there is an implicit type casting thats taking place at the left hand side of the operator for only one time. Example;
x=x+1.5 // error
x+=1.5+3.5; "+" in the right hand side adds up 1.5 and 3.5,, "+" doesnt work !!(mathematics), all it does is a type casting !!
you check the difference between statements "x=3.5+4.5" x is an int and "x+=3.5+4.5" you will know it better , whats happening at the left hand side .
and also analyse what would a compiler do in this case for better understanding.
x is int;
x=1.5+4.55555555555555555555555555555555555555555555;

compiler would be so confused !! how many type castings !!.
so implicit type casting is done at left hand side for only one time, ;


hope you have got my point, thanks for posting this question, IT makes me think a llot !!!
9 years ago
Its good to try something new and ask ourselves "why this" . In the above code, you have declared the variable as a private !. by making it private, you cannot access that variable outside your class , and that variable you have declared in abstract class,and you need to implement all the entities in the concrete class down the tree, so it would be good if you try with access specifiers "protected" and default" to know the difference !! keep trying for all the options you have, to enjoy the java !!! good luck.
9 years ago

Paul Clapham wrote:In real-world situations you should use StringBuilder now. The scenarios where you would want to use StringBuffer because the methods are synchronized are extremely unlikely -- I can't envisage anybody ever wanting to use multiple threads trying to operate on a StringBuffer simultaneously.


A tonne of thanks,
9 years ago
A big Hello to all JavaRanch fans, This is my first post and I'm happy. coming to question, Please tell me any real world examples for StringBuilder and StringBuffer and clarify me in which scenarios i should use these , I've read about these in many textbooks, but I get only "thread safe", but not any real world example. help is needed and thanks in advance !!!
9 years ago