Results 1 to 6 of 6

Thread: noob question!

  1. #1
    swp
    swp is offline Member
    Join Date
    Sep 2011
    Posts
    9
    Rep Power
    0

    Default noob question!

    this is a call from my main. prior to this i have declared a first seq, set1 and another, set2.

    doubleArraySeq finalSet = doubleArraySeq.concatenation(set1, set2);

    the method concatenation is supposed to make the two seq into one seq called finalset.
    i haven't coded the actual method but for compile-ing's sake i just have written the return statement ->

    public static doubleArraySeq concatenation(doubleArraySeq s1, doubleArraySeq s2){

    return finalset;


    }

    it wont let me say return finalset. so my questions are


    1)should i even be writing the code to add the two sequences set1 and set2 together in this method?
    2)if so how do i return the values (or the full array of set1 and set2 (finalset) ) to the main function?


    please help and thanks in advance!!

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default Re: noob question!

    You need to declare finalset as a doubleArraySeq variable first within the method. For example...

    Java Code:
    public static doubleArraySeq concatenation(doubleArraySeq s1, doubleArraySeq s2){
       // you first need to declare the variable before you can use it.
       doubleArraySeq finalset = null;
       
       // your code that figures out how to create a finalset that combines s1 and s2 goes here
    
       return finalset;
    }
    Note that you can declare the variable and create the object that combines s1 and s2 all on one line if you wish.

  3. #3
    swp
    swp is offline Member
    Join Date
    Sep 2011
    Posts
    9
    Rep Power
    0

    Default Re: noob question!

    sweet that helps out!

    but what do you mean i could do it all in one line? dont i have to like copy the stuff from set2 and place it at where set one ends?

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default Re: noob question!

    The way my code is written, I've declared the finalset on one line and then have a comment where a second line would go where you would use s1 and s2 to create an object to have finalset refer to. If you desire this can all be done on one line. For example the following is equivalent:

    Java Code:
    // this:
    int a = 0;
    a = 4 + 8;
    
    //is equivalent to this:
    int b = 4 + 8; // but this does it all on one line

  5. #5
    swp
    swp is offline Member
    Join Date
    Sep 2011
    Posts
    9
    Rep Power
    0

    Default Re: noob question!

    i understand that, but i can't just say can i?

    doubleArraySeq finalSet = set1 + set2;

    actually i know i cant ha ha that's just silly. but is that kinda what your saying?

  6. #6
    swp
    swp is offline Member
    Join Date
    Sep 2011
    Posts
    9
    Rep Power
    0

    Default Re: noob question!

    do you think you could help me out with one more thing?

    once again sorry im new :/

    i have another method that is called start() and that's supposed to set 'current' to the first thing in the sequence.

    i just don't know where and how to say that, in the actual start method?

    so would i say something like current = set1.addAfter(10) for example?

    because the addAfter method relies on current, so i just don't see how to connect the dots in my head!

Similar Threads

  1. noob question. plz help tho!
    By swp in forum New To Java
    Replies: 2
    Last Post: 09-28-2011, 06:16 AM
  2. Hi guys! Noob question...
    By moominboy in forum New To Java
    Replies: 1
    Last Post: 09-26-2011, 04:43 PM
  3. Probably Really Noob Question
    By bpx95 in forum New To Java
    Replies: 2
    Last Post: 05-16-2011, 01:44 AM
  4. Reallyy noob question
    By x2robbie2x in forum New To Java
    Replies: 3
    Last Post: 02-18-2010, 04:58 AM
  5. Question - I'm a noob!
    By Insaeno in forum New To Java
    Replies: 5
    Last Post: 08-04-2008, 03:20 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •