Results 1 to 5 of 5

Thread: Java basic

  1. #1
    chinthanabt is offline Member
    Join Date
    Dec 2013
    Posts
    3
    Rep Power
    0

    Default Java basic

    String st="hello";
    st+="world";

    strings are imutable so what willl happen here;

    please help me

    thax.

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,826
    Rep Power
    22

    Default Re: Java basic

    Moving thread to New To Java, as that's a better home than the JDK sub forum.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  3. #3
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    14,292
    Blog Entries
    7
    Rep Power
    24

    Default Re: Java basic

    At the end of that code snippet, st refers to a new String "helloworld" and the two other Strings "hello" and "world" are to be destroyed by the garbage collector (if possible).

    kind regards,

    Jos
    The only person who got everything done by Friday was Robinson Crusoe.

  4. #4
    chinthanabt is offline Member
    Join Date
    Dec 2013
    Posts
    3
    Rep Power
    0

    Default Re: Java basic

    i saw video on you tube it says;

    st=new StringBuffer("hello").append("world");

    please expalin me, is this correct

    thax.

  5. #5
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    5,114
    Rep Power
    9

    Default Re: Java basic

    Does it work?
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

Similar Threads

  1. basic java + ms sql
    By selomojemalo in forum New To Java
    Replies: 4
    Last Post: 08-06-2013, 08:47 AM
  2. basic java
    By sukeerthi in forum New To Java
    Replies: 3
    Last Post: 06-30-2012, 11:33 AM
  3. Java Basic
    By Anveshan in forum New To Java
    Replies: 6
    Last Post: 05-06-2011, 09:45 AM
  4. Basic java
    By santa in forum New To Java
    Replies: 5
    Last Post: 11-16-2009, 11:16 AM
  5. basic java help
    By adred in forum New To Java
    Replies: 0
    Last Post: 03-08-2008, 01:36 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •