• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

primitve assignments

 
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The c is a char,The s is a String,The result is a String when the c + s or s + c
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic