Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.help > #1094

Re: <identifier> expected error

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.chainon-marquant.org!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!74.125.46.80.MISMATCH!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail
From Lew <lewbloch@gmail.com>
Newsgroups comp.lang.java.help
Subject Re: <identifier> expected error
Date Thu, 22 Sep 2011 17:56:03 -0700 (PDT)
Organization http://groups.google.com
Lines 47
Message-ID <30653042.1413.1316739363176.JavaMail.geo-discussion-forums@prfp37> (permalink)
References <c4db596b-eb82-4d41-bfd6-372b4037bfca@l2g2000vbn.googlegroups.com>
Reply-To comp.lang.java.help@googlegroups.com
NNTP-Posting-Host 2620:0:1000:fd42:224:d7ff:fe69:5838
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1
X-Trace posting.google.com 1316739363 1894 127.0.0.1 (23 Sep 2011 00:56:03 GMT)
X-Complaints-To groups-abuse@google.com
NNTP-Posting-Date Fri, 23 Sep 2011 00:56:03 +0000 (UTC)
In-Reply-To <c4db596b-eb82-4d41-bfd6-372b4037bfca@l2g2000vbn.googlegroups.com>
Complaints-To groups-abuse@google.com
Injection-Info glegroupsg2000goo.googlegroups.com; posting-host=2620:0:1000:fd42:224:d7ff:fe69:5838; posting-account=CP-lKQoAAAAGtB5diOuGlDQk0jIwmH0T
User-Agent G2/1.0
X-Google-Web-Client true
Xref x330-a1.tempe.blueboxinc.net comp.lang.java.help:1094

Show key headers only | View raw


Kathy Walker wrote:
> Gah. I'm trying to call a method from one class to another. The TA's [sic]
> are overloaded so I got no one, can anyone tell me what's wrong? I've
> had one java [sic] class like a year ago. Kinda rusty. Thanks!
> 
> class NumArrayList implements NumList
> {
>   double [] Numbers = new double[3];
> 
>   public void main(String args[]){
> 
>     Numbers[0] = 100000;
>     Numbers[1] = 20.9;
>     Numbers[2] = 3;
>   }
>   public  void printArray(){
>   for(int i = 0; i<Numbers.length;i++)
>     System.out.print(Numbers[i] + " ");
>   }
> }
> 
> -----------------------------------------------------------------------------> 
> public interface NumList {
> printArry();
> }

So what is the problem you face?

You have left out a lot of details, like what is expected and what's happening instead, and what you're doing to make that happen, but I'll tell you what I see so far.

"... trying to call a method from one class to another."
You don't show any class trying to call a method from another class, or even from itself.

"public void main(String args[]){"
The Java Virtual Machine (JVM) needs a public *static* void main method to start a Java program.  Your 'main()' is not 'static'.

Your 'for' loop lacks curly braces around its statement body.

You named your number array 'Numbers'.  The convention in Java is for variables to start with a lower-case letter, not an upper-case letter. Type (class and interface) names should begin with an upper-case letter.

'System.out.print(...)'
You should follow your last 'print()' with a 'println()' or you risk not seeing any output at all, because 'System.out' is buffered.  A newline (which 'println()' emits) forces a flush to the 'out' stream.  The flush empties the buffer to the stream.

Provide more details about your problem, such as what the error message is (verbatim!); a short, self-contained, compilable example (http://sscce.org/) that demonstrates the error; and the operating conditions that let someone duplicate your error.

-- 
Lew

Back to comp.lang.java.help | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

<identifier> expected error Kathy Walker <kjata1013@gmail.com> - 2011-09-22 16:40 -0700
  Re: <identifier> expected error "John B. Matthews" <nospam@nospam.invalid> - 2011-09-22 20:54 -0400
    Re: <identifier> expected error Kathy Walker <kjata1013@gmail.com> - 2011-09-22 18:08 -0700
      Re: <identifier> expected error "John B. Matthews" <nospam@nospam.invalid> - 2011-09-22 21:24 -0400
  Re: <identifier> expected error Lew <lewbloch@gmail.com> - 2011-09-22 17:56 -0700
    Re: <identifier> expected error Kathy Walker <kjata1013@gmail.com> - 2011-09-22 18:09 -0700
  Re: <identifier> expected error Roedy Green <see_website@mindprod.com.invalid> - 2011-09-23 02:30 -0700
  Re: <identifier> expected error Roedy Green <see_website@mindprod.com.invalid> - 2011-09-23 02:32 -0700
    Re: <identifier> expected error Lew <lewbloch@gmail.com> - 2011-09-23 12:10 -0700
      Re: <identifier> expected error Roedy Green <see_website@mindprod.com.invalid> - 2011-09-23 17:10 -0700
        Re: <identifier> expected error Lew <lewbloch@gmail.com> - 2011-09-23 17:56 -0700
          Re: <identifier> expected error Roedy Green <see_website@mindprod.com.invalid> - 2011-09-25 00:13 -0700

csiph-web