Ask Experts Questions for FREE Help !
Ask
    jkj90's Avatar
    jkj90 Posts: 1, Reputation: 1
    New Member
     
    #1

    Sep 8, 2013, 03:53 AM
    JAVA Mutable and Immutable concept
    String str=new String("JAVA");
    System.out.println("value of str before "+str); //JAVA
    String str2=null;
    str=str2;
    System.out.println("value of str"+str); //null
    System.out.println("value of str2"+str2);//null

    str="Prog";
    System.out.println("value of str"+str); //prog
    System.out.println("value of str2"+str2);//null
    Ques 1 If string is immutable why is value of str changing?

    Student stu= new Student(123);
    System.out.println("value of stu before "+stu); //some address is printed
    Student stu2=null;
    stu=stu2;
    System.out.println("value of stu"+stu); //null
    System.out.println("value of stu2"+stu2);//null
    Student stu3=new Student(456);
    stu=stu3;
    System.out.println("value of stu"+stu); //some new address
    System.out.println("value of stu2"+stu2);//null
    Ques 2.String and Object are behaving in same way .Then why String is immutable and Object mutable. Where's the difference

Check out some similar questions!

Transformer concept [ 4 Answers ]

If I generate 1 volt a.c. and with a 1:240 transformer , I step up it to 240 volts then can I lit a 100 watts (240 volts , rated) bulb at its full intensity, from the output terminals? If not then why? What are the parameters limiting this to happen? The windings, wires? source? Or what? Please...

Java netbeans program- Connection between java and mysql,How to conn [ 0 Answers ]

which I wrote from a book but when I run it, it shows exception please give me the code to connect jlistbox to database when I click on btn1. btn coding should search "name" in database and shows all the names in listbox my coding: here-- r1,r2,r3 are radio btns and l1,l2,l3 are labels,...

Accounting concept [ 1 Answers ]

Please give me the answer accounting concept for ICWAI inter study

Concept paper [ 2 Answers ]

What is a concept paper? How do I write it? How can I create a thesis statement?


View more questions Search
 

Question Tools Search this Question
Search this Question:

Advanced Search

Add your answer here.