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: Function that will add the contents of a String array

  1. #1
    Junior Member
    Join Date
    Sep 2014
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Post Function that will add the contents of a String array

    Write a function that will add the contents of a String array.
    1. This time the input array to your function will be an array of Strings.
    2. Your function body will be similar except you’ll have to convert each String
    to a double number.

    public class SumVals2 {
    String aryVals[];
    double result;
    /* Add code here to instantiate an array of String that can hold 8
    elements */
    /* Next add code like the line below to add 4 elements to the array */
    aryVals[0] = “5.25”;
    result = sumStrAry(aryVals, 2);
    System.out.println(“Result 1: “ + result);
    /* Add code here to instantiate 2 more String objects and add them to
    the array */
    result = sumStrAry(aryVals, 4);
    System.out.println(“Result 2: “ + result); } /* Add your function here! */
    }


  2. #2
    Member
    Join Date
    Aug 2013
    Posts
    95
    Thanks
    3
    Thanked 14 Times in 14 Posts

    Default Re: Function that will add the contents of a String array

    First of all please post your code inside the code tags like so
     //code goes here

    Secondly what is your question?

    Thirdly you do not have any memory allocated for your aryVals array. you need to give it a certain size you want.

  3. #3
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: Function that will add the contents of a String array

    Welcome to the Forum! Please read this topic to learn how to post code correctly and other useful tips for newcomers.

    After looking at your other post, you appear to believe this forum takes orders and provides code, a code writing service. That's not what we do. We'll help you with your code. Please return when you have some code you'd like help with.

    Threads closed.

Similar Threads

  1. Add drawing function MouseMotionEventListener program?
    By crzybldthrwr in forum What's Wrong With My Code?
    Replies: 33
    Last Post: September 1st, 2012, 04:42 PM
  2. How do I display the contents of this array?
    By mjballa in forum What's Wrong With My Code?
    Replies: 2
    Last Post: December 7th, 2011, 02:17 AM
  3. Re-Initialize array without loosing contents..
    By Mr.777 in forum Java Theory & Questions
    Replies: 7
    Last Post: June 17th, 2011, 05:47 AM
  4. Reading in entire contents of text file to one string
    By fortune2k in forum File I/O & Other I/O Streams
    Replies: 9
    Last Post: December 12th, 2010, 07:03 PM
  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