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

Thread: Basic programming and arrays please help!

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

    Default Basic programming and arrays please help!

    The question is
    "In Q1A write a method called getIntArraySize8() that returns an array
    that can store 8 integers. "
    It also says you should have only one statement in the method

    my code is

    public class Q1A {
    int [] getIntArraySize8(){
    int [] questionOne = new int[8];
    return questionOne;
    }
    }

    How do I make it so its only one statement?

    By the way I use bluej
    Thanks!


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

    Default Arrays

    The exercise question is

    "In Q1A write a method called getIntArraySize8() that returns an array
    that can store 8 integers."
    It also says you only need one statement in the method

    My code is

    public class Q1A {
    int [] getIntArraySize8(){
    int [] questionOne = new int[8];
    return questionOne;
    }
    }

    How do change so that there is only one statement

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

    Unhappy Creating a method

    Another exercise q

    "In Q1B write a method called getIntArraySizeN() that takes an integer
    parameter called length and returns an array that can store that many
    integers."
    It says there only needs to be one statement

    My code is

    public class Q1B {
    int[] getIntArraySizeN(){
    int length=10;
    int[] lengthArray = new int[length];
    return lengthArray;
    }

    }

    I know im not supposed to create a variable but I have no idea what to do. Please help?

  4. #4
    Member
    Join Date
    Apr 2014
    Posts
    219
    Thanks
    8
    Thanked 2 Times in 2 Posts

    Default Re: Creating a method

    Please edit your post and wrap your code with code tags:
     
    [code=java]
     
    YOUR CODE GOES HERE //to make it look like this

    [/CODE]
    to get highlighting and preserve formatting.

    Look into ArrayList in the API...

  5. #5
    Member
    Join Date
    Apr 2014
    Posts
    219
    Thanks
    8
    Thanked 2 Times in 2 Posts

    Default Re: Arrays

    This is the same question you just posted but with a different title.

  6. #6
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,520
    My Mood
    Mellow
    Thanks
    215
    Thanked 697 Times in 679 Posts

    Default Re: Basic programming and arrays please help!

    Welcome to the forum! Please read this topic to learn how to post code in code or highlight tags and other useful info for new members.

    Please post your code correctly using code or highlight tags per the above link.

    Please do not post multiple threads on the same topic. Threads merged.

Similar Threads

  1. Java Programming (Object Oriented Programming) Assignment
    By azmilPhenom in forum Object Oriented Programming
    Replies: 3
    Last Post: December 21st, 2013, 07:26 AM
  2. Programming a basic back and forth model?
    By exquisitus in forum Java Theory & Questions
    Replies: 1
    Last Post: June 24th, 2012, 05:26 PM
  3. Need some JAVA basic programming help
    By joregorn in forum Java Theory & Questions
    Replies: 11
    Last Post: March 22nd, 2012, 08:30 PM
  4. Replies: 0
    Last Post: December 12th, 2011, 03:17 PM
  5. Basic Obj programming help! thanks
    By mclaren93 in forum Object Oriented Programming
    Replies: 1
    Last Post: November 17th, 2011, 07:45 PM