This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes primitve assignments Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "primitve assignments" Watch "primitve assignments" New topic
Author

primitve assignments

Smitha Ballikar
Ranch Hand

Joined: Aug 02, 2005
Posts: 99
Hi,

A Enter
Greenhorn

Joined: Aug 16, 2005
Posts: 20
The c is a char,The s is a String,The result is a String when the c + s or s + c
Pulamathi Pavan Kumar
Greenhorn

Joined: May 31, 2005
Posts: 6
In Java only operator overloaded is " + ".

U cannot append character with a string since + is used only with Strings.
in the second line s+=c,

Everything that gets appended to String will be converted to String.So it works in the second case.
For ur clarification,

int i=2,j=4;
String str="abc";
System.out.println(str+i+j);
System.out.println(i+j+str);

Outputs will be:
(1) abc 2 4-----> If anything appended after a string, entire is a string.
(2) 6 abc

Hope this shuld help...

pavan.
 
Have you checked out Aspose?
 
subject: primitve assignments
 
It's not a secret anymore!