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 3 of 3

Thread: How do I display the contents of this array?

  1. #1
    Junior Member
    Join Date
    Nov 2011
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default How do I display the contents of this array?

    This might be a stupid question to some people. Sadly I am a rookie programmer. This is my task: Display the contents of the array by using a
    method that receives the array as a parameter and uses System.out. and here is my code:
    import java.util.Scanner;
     
    public class Lab10_Ex3
    {
    	public static void main(String[] args)
    	{		
    		String[] scientists = {"Einsten", "Newton", "Copernicus", "Kepler"};
    		strings(scientists);
    	}
    	public static void strings(String[] array)
    	{
    		Scanner keyboard = new Scanner(System.in);
     
    		System.out.print(array);
    	}
    }

    for some reason this comes up as the output:
    [Ljava.lang.String;@61de33


  2. #2
    Junior Member
    Join Date
    Nov 2011
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: How do I display the contents of this array?

    Nevermind I got it!

  3. #3
    Think of me.... Mr.777's Avatar
    Join Date
    Mar 2011
    Location
    Pakistan
    Posts
    1,136
    My Mood
    Grumpy
    Thanks
    20
    Thanked 82 Times in 78 Posts
    Blog Entries
    1

    Default Re: How do I display the contents of this array?

    Quote Originally Posted by mjballa View Post
    Nevermind I got it!
    Kindly mark it as SOLVED

Similar Threads

  1. Re-Initialize array without loosing contents..
    By Mr.777 in forum Java Theory & Questions
    Replies: 7
    Last Post: June 17th, 2011, 06:47 AM
  2. Replies: 2
    Last Post: May 13th, 2011, 04:08 AM
  3. [SOLVED] Display 2d array aligment
    By Scotty in forum Collections and Generics
    Replies: 0
    Last Post: November 26th, 2010, 03:37 PM
  4. Reading contents of another window
    By jimmys in forum Java Theory & Questions
    Replies: 8
    Last Post: October 5th, 2010, 12:40 AM
  5. How to create a sorted set from the contents of an array
    By davie in forum Collections and Generics
    Replies: 1
    Last Post: March 11th, 2010, 03:44 PM