• 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

string problem

 
Greenhorn
Posts: 13
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am confused in String.It's given in the book that string is object in java and it is created by using the class "String".And if you write "Object ob" then only the reference of that class is created and it points to "Null",an object is created by using "new" operator,"Object ob=new Object()".
Since the objects are created by using "new" operator where the memory is allocated dynamically during run-time, how in case of string this given statement is possible "String ob="Hello",without allocating memory for it.


any help is appreciated...
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
String is special - the Java language has special syntax for creating strings. Suppose there were no string literals in Java, then it would be incredibly cumbersome to initialize a String object with separate characters. You'd have to do something like this:

 
riteshhh kumar singh
Greenhorn
Posts: 13
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
so,it's a special case in java.
okay,thank you jesper,thankx for the help
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic