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

Thread: RainFall Programming

  1. #1
    Junior Member
    Join Date
    May 2014
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default RainFall Programming

    I have written program for rainfall that will store and give total, average, least and most. The program stores the input of rainfall for each month. However at the end it suppose to print out the month with the least and most rainfall. I am getting this on the print for
    The month with the most rainfall: [Ljava.lang.String;@79a7bd3b
    and for
    The month with the least rainfall: [D@7378aae2[Ljava.lang.String;@79a7bd3b
    . What have i done wrong?


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: RainFall Programming

    The String in the printout: [Ljava.lang.String;@79a7bd3b is the String returned by a String array's default toString() method. The compiler generates a call to the toString() method when an array is concatenated to a String.
    [D@7378aae2 is from the default toString() method for an array of doubles.

    There normally is no reason to print the full contents of an array, except for when debugging.
    Did you intend to index into the arrays to extract an element to show?
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    May 2014
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: RainFall Programming

    Yes, I need for it to show the month.

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: RainFall Programming

    If the data you want to show is an element in an array, the code needs to index into the array to get it:
    theArray[theIndex]
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Junior Member
    Join Date
    May 2014
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: RainFall Programming

    Ok, Thank you

Similar Threads

  1. [SOLVED] Average Rainfall Main Class Using nested for loops,input validation - Average is off
    By CyberOps in forum What's Wrong With My Code?
    Replies: 3
    Last Post: February 24th, 2014, 05:36 AM
  2. Java Programming (Object Oriented Programming) Assignment
    By azmilPhenom in forum Object Oriented Programming
    Replies: 3
    Last Post: December 21st, 2013, 07:26 AM
  3. creating a rainfall class
    By brayanG22 in forum What's Wrong With My Code?
    Replies: 6
    Last Post: October 11th, 2013, 02:28 PM
  4. android programming vs game programming using java
    By vgoel38 in forum Android Development
    Replies: 4
    Last Post: September 8th, 2012, 05:48 PM
  5. Replies: 0
    Last Post: December 12th, 2011, 03:17 PM