Results 1 to 3 of 3
  1. #1
    swp is offline Member
    Join Date
    Sep 2011
    Rep Power

    Default noob question. plz help tho!

    being very new to java, im just working on a few easy projects, and was wondering if i could get some advice.

    im supposed to declare an array in the main function and this is what i said:

    double[ ] ar1 = new double[10];

    an array that takes on double numbers. But what i don't know how to do is to refer to it in the methods of the class.

    this is the method which i am trying to refer to the array in:

    public void start(){
    current = ar1[0];

    im just trying to create a current variable that keeps track of obviously the current element in the array.

    how would i go about doing so please help me im DYING OVER HERE :(

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Blog Entries
    Rep Power

    Default Re: noob question. plz help tho!

    If that array is declared in the main method, then it is only visible inside of the main method and no where else. If you want the start method to act on it, consider changing start so it will allow you to pass in an array parameter. Also, if you're calling start from inside of the static main method, does start need to be static too?

  3. #3
    tnrh1 is offline Senior Member
    Join Date
    Aug 2011
    Rep Power

    Default Re: noob question. plz help tho!

    Java Code:
    public static void(double [] ar){
         for(int k=0;k<ar.length;k++){
              do here what ever you want;
    Read Fubarable replay also.

Similar Threads

  1. Hi guys! Noob question...
    By moominboy in forum New To Java
    Replies: 1
    Last Post: 09-26-2011, 05:43 PM
  2. Probably Really Noob Question
    By bpx95 in forum New To Java
    Replies: 2
    Last Post: 05-16-2011, 02:44 AM
  3. Reallyy noob question
    By x2robbie2x in forum New To Java
    Replies: 3
    Last Post: 02-18-2010, 05:58 AM
  4. Question - I'm a noob!
    By Insaeno in forum New To Java
    Replies: 5
    Last Post: 08-04-2008, 04:20 AM
  5. Noob question- easy
    By mattonitto in forum New To Java
    Replies: 7
    Last Post: 06-13-2008, 01:26 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