Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: code explaination

  1. #1
    Member
    Join Date
    Jan 2012
    Posts
    57
    My Mood
    Fine
    Thanks
    11
    Thanked 0 Times in 0 Posts

    Default code explaination

    hiii guys

    here is a piece of code .. which i m not able to understand the output of this code

    public class Main {
     
     
        public static void main(String[] args)
    {
            int a[]={1,2,3};
            int b[]={1,2};
            System.out.println(a==b);
            System.out.println(a);
     
        }
    }

    output : False
    [I@3e25a5
    Last edited by deependeroracle; February 16th, 2012 at 11:50 PM.


  2. #2
    Junior Member
    Join Date
    Nov 2011
    Posts
    7
    My Mood
    Busy
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: code explaination

    bcz u r comparing two arrays addresses ,that is why it is giving false.
    and second one it is printng the address of Array a.

  3. #3
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,318
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: code explaination

    which i m not able to understand the output of this code
    What don't you understand? What do you expect?

  4. #4
    Member
    Join Date
    Jan 2012
    Posts
    57
    My Mood
    Fine
    Thanks
    11
    Thanked 0 Times in 0 Posts

    Default Re: code explaination

    @super Moderator
    Actually the first output is clear to me which was False..
    but for the second value i have doubt .. is it a reference value or it is address ???? my answr is that it is a reference value .. bczzz wen every time i run the code it gives the same reference value ....and in case of address it alwayz get changed .. plz specify the correct reason if i am wrong

    Thanks

Similar Threads

  1. code to refresh and check the code of a webpage..
    By vaggelis in forum What's Wrong With My Code?
    Replies: 1
    Last Post: February 7th, 2012, 07:43 AM
  2. Help merging program code with GUI code
    By Wilha in forum AWT / Java Swing
    Replies: 2
    Last Post: January 25th, 2012, 07:03 PM
  3. problem in my code java code graph editeur
    By kisokiso in forum Java Theory & Questions
    Replies: 5
    Last Post: January 6th, 2012, 08:36 AM
  4. Code is giving an error in console, but there are no errors apparent in the code!
    By JamEngulfer221 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: November 15th, 2011, 09:30 PM
  5. describe this program code by code ....
    By izzahmed in forum What's Wrong With My Code?
    Replies: 2
    Last Post: October 29th, 2011, 11:03 PM