• 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

pool and heap

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Q1,what is the basic and main differences b/w pool and heep?
Q2,what is the difference b/w String and String Buffer???
Q3, Is there any difference when we use brakets in the following Expression?
int i=2, j=3;
int k=((i++) + (--j) + (++i) + (j--));
Or
int k=(i++ + --j + ++i + j--);
Note Please try to explain these quetions with exampleS...)
Allah Hafiz
and
Thanx in advance
Kamran and Zia
(Badarians)
 
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

If the Q1 refers to String (??) then perhaps the main diff. is that:
a) Strings from the pool are not gc. and
b) the following code gives true and false
public class A
{
public static void main(String args[]) //2
{
String s = "baba";
String t = "baba";
String s1 = new String("baba");
String t1 = new String("baba");
System.out.println(s==t);
System.out.println(s1==t1);
}

}

q2 Perahps the main(?) difference is that : "StringBuffer class represents a string that can be dynamically modified" RHE.
StringBuffer append(String str)...modifies the StringBuffer on which was called
String concat(String str).... generates a new string and keeps the one on which you called the method unmodified.
public class A
{
public static void main(String args[]) //2
{
String string = "one";
StringBuffer buffer = new StringBuffer("one");
String test1 = string.concat("two");
StringBuffer test2 = buffer.append("two");
System.out.println(string + " "+ test1);//string remains the same
System.out.println(test2==buffer);

}

}
q3. I don't see any difference as ++ and -- have higher priorities than + and -.
..Cristian
reply
    Bookmark Topic Watch Topic
  • New Topic