Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / December 2007

Tip: Looking for answers? Try searching our database.

Identifier expected error.

Thread view: 
Art Cummings - 10 Dec 2007 04:50 GMT
Good evening all,

Is there a way to have a static array in my OneStudent class?  When I try to
do it, i'm getting an <identifier> expected error.  If there is a way to do
it, can you tell me how?

Thanks Art

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.text.DecimalFormat;
import java.util.ArrayList; // to use array list
import java.util.Scanner; // Needed for the Scanner class
import java.io.*;         // Needed for the File class

//Student class

public class OneStudent
{
          private static double  grade;
          private static String name;
          private static int thesize, myindex;
          private static ArrayList list = new ArrayList();
          private static int currentindex=0;
          private static double(double [][]scores);**************This is
the array

          //constructors for name
          public void setName(String sName,int indx)
          {
                     System.out.println(list.size()+" This is list size");
          System.out.println(indx+" This is index");
          System.out.println(sName);

          list.add(list.size(), sName);
          System.out.println(list.size()+" This is now list size");
          //setIndex(list.size());
          }

          //constructor for getting name
          public String getName(int indx)
          {
          name = list.get(indx).toString();
          return name;
          }

          //constructor to set grades
          public void setGrade(double[][]Grades,int row,int col)
          {
          grade = Grades[row][col];
          System.out.println(list);

          }

          //constructor to get grades
          public double getGrade(int row, int col)
          {
          //static double(double[][]scores);

          return grade;
          }

                     //constructor to getting size of arraylist
          public int getSize()
          {
          int size=0;
          size = list.size();
          return size;
          }

          public void setIndex(int ndx)
          {
          myindex = ndx;

          }

          public int  getIndex()
          {
          System.out.print(myindex);
          return myindex;
          }

          public void setCurrent(int indx)
          {
          currentindex = indx;
          }

          public int getCurrent()
          {
          return currentindex;
          }

}
Eric Sosman - 10 Dec 2007 05:16 GMT
> Good evening all,
>
[quoted text clipped - 23 lines]
>            private static double(double [][]scores);**************This is
> the array

    Perhaps you mean

    private static double[][] scores;

or possibly

    private static double[][] scores
       = new double[ROWS][COLS];

or something of the sort.  (It's hard to be sure what you
want, since the code you posted doesn't make any use at all
of `scores' except in the botched declaration and in a similar
commented-out line.  Unable to divine your intent, I can't
be sure my suggestions will help you achieve it.)

Signature

Eric Sosman
esosman@ieee-dot-org.invalid

Lew - 10 Dec 2007 08:03 GMT
Art Cummings wrote:
>> Is there a way to have a static array in my OneStudent class?  When I
>> try to do it, i'm getting an <identifier> expected error.  If there is
>> a way to do it, can you tell me how?

Art:

READ THE TUTORIAL!

Signature

Lew

Art Cummings - 10 Dec 2007 10:28 GMT
> Art Cummings wrote:
>>> Is there a way to have a static array in my OneStudent class?  When I
[quoted text clipped - 4 lines]
>
> READ THE TUTORIAL!

I promise to read it cover to cover as soon as this class is over Tuesday.
Lew, i'm trying to assign the result of an ArrayList insert to a variable,
like this....

               String hold;
              ArrayList nameList = new ArrayList();
               hold = nameList.add(1, 56);

I'd like to be able to assign this to a double ultimately.  Can you help me
with the syntax?

Thanks

Art
cddcdd@gmail.com - 10 Dec 2007 11:13 GMT
> > Art Cummings wrote:
> >>> Is there a way to have a static array in my OneStudent class?  When I
[quoted text clipped - 22 lines]
>
> Art

Hi, method "Array.add(int index, E element)" return void, how can you
assign this to a String?
Lew - 10 Dec 2007 15:17 GMT
>> Art Cummings wrote:
>>>> Is there a way to have a static array in my OneStudent class?  When I
[quoted text clipped - 7 lines]
> Lew, i'm trying to assign the result of an ArrayList insert to a variable,
> like this....

You ask question after question after question after question that would take
so much less time FOR YOU if you read the tutorial, but instead you take more
time coming to the newsgroup, unable to use the answers because you absolutely
refuse to do the minimum that would make /your/ life easier, and expect us to
take up the slack.  That is illogical and exploitative behavior.

READ THE TUTORIAL!

TODAY!

Signature

Lew

Art Cummings - 10 Dec 2007 16:49 GMT
Thanks Lew, you da man.

Art
>>> Art Cummings wrote:
>>>>> Is there a way to have a static array in my OneStudent class?  When I
[quoted text clipped - 18 lines]
>
> TODAY!
Lew - 11 Dec 2007 01:46 GMT
> Thanks Lew, you da man.

Honestly, I said what I did for your benefit, and knowing that Eric Sosman had
already given the primary answer to your question.

Rest assured that I'll continue to answer your specific questions (if I know
the answer and someone else hasn't already and I'm in an answering mood
anyway), regardless of whether you've read the tutorial yet.

I'm emphasizing the tutorial so much because it doesn't take long to read
whatever section is relevant, or to find that section with the table of
contents, and it's relatively well-written if rather brief.  Even if you just
skim lightly over it it will prime your brain for information obtained from
other sources, such as here.

Please do not think I would withhold assistance over this - I want you to succeed.

Signature

Lew

Art Cummings - 11 Dec 2007 05:53 GMT
> I'm emphasizing the tutorial so much because it doesn't take long to read
> whatever section is relevant, or to find that section with the table of
[quoted text clipped - 4 lines]
> Please do not think I would withhold assistance over this - I want you to
> succeed.

Thanks for everything Lew.  I was taking 2 really difficult classes from the
same instructor and it was overwhelming at times.  Sometimes I just wanted
to find a quick answer.  I've already started reading the tutorial and i'm
finding that there are things I do and don't understand.  I plan to read it
and review my text during the break.  I still don't have a good
understanding of the concept behind classes.  This is one of the major
issues i've identified in my confusion.  Thanks again for all your help,
present and future.

Art
Nigel Wade - 10 Dec 2007 17:12 GMT
>> Art Cummings wrote:
>>>> Is there a way to have a static array in my OneStudent class?  When I
[quoted text clipped - 12 lines]
>                ArrayList nameList = new ArrayList();
>                 hold = nameList.add(1, 56);

What is this supposed to do? The add() method of ArrayList is void, it does not
return a String. Also it accepts arguments of type (int, E) where E is the
class defined by generics to be the type of Object which the array list holds.
You haven't specified what type of object your ArrayList is supposed to hold so
it will hold any object without any type checking. You have managed to store an
Integer because of primitive type "boxing". But we've no idea if that is what
you really intended to do or not.

Please, do as Lew suggests and read the tutorials.

> I'd like to be able to assign this to a double ultimately.  

Assign what to a double? I see nothing in the above code which could be assigned
to a double.

> Can you help me  
> with the syntax?

No, because I don't have a clue what you are trying to do.

Signature

Nigel Wade, System Administrator, Space Plasma Physics Group,
           University of Leicester, Leicester, LE1 7RH, UK
E-mail :    nmw@ion.le.ac.uk
Phone :     +44 (0)116 2523548, Fax : +44 (0)116 2523555

Art Cummings - 10 Dec 2007 19:20 GMT
>>> Art:
>>>
>>> READ THE TUTORIAL!
>
> Please, do as Lew suggests and read the tutorials.

Thanks to all, and now as promised I will read the tutorial.  I got an A by
the way.

Art
Lew - 11 Dec 2007 01:49 GMT
Nigel Wade wrote:
>> Please, do as Lew suggests and read the tutorials.

Art: you generally are doing a good job organizing your posts, trimming
extraneous quotes, answering in line - all those good behaviors.  It is also
helpful to cite who posted what you're quoting, in order to help other folks
understand the context.

> Thanks to all, and now as promised I will read the tutorial.  I got an A by
> the way.

Mazeltov!

Signature

Lew

Roedy Green - 23 Dec 2007 05:23 GMT
> <identifier> expected error
http://mindprod.com/jgloss/compileerrormessages.html#IDENTIFIEREXPECTED
Signature

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.