Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-22-2008, 09:35 PM
Member
 
Join Date: May 2008
Posts: 1
rmartyce is on a distinguished road
symbol not found error
I have a program (see below). Can someone tell me why I'm getting the error...

C:\CourseUnits.java:95: cannot find symbol
symbol : variable CourseUnitArray
location: class CourseUnits
CourseUnitArray[0] = new CourseUnits("name","num");
^
C:\CourseUnits.java:95: cannot find symbol
symbol : constructor CourseUnits(java.lang.String,java.lang.String)
location: class CourseUnits
CourseUnitArray[0] = new CourseUnits("name","num");
^
2 errors

Tool completed with exit code 1

The CourseUnits constructor is there. The classpath is .;PATH;C:\;
I've been stumped for 2 days, so any assistance is greatly appreciated.



import java.lang.*;
import java.util.*;
import java.io.*;
import java.util.Scanner;

public class CourseUnits {
private Integer courseUnitID;
private String courseUnitName;
private String courseUnitNum;
private static int lastAssignedID = 10000;
//in the real world the ArrayList would not be used. Instead a datbase table would
//be used.
private static ArrayList<CourseUnits> courseUnitArray = new ArrayList<CourseUnits>();


//default constructor - no parameters
public void CourseUnits(){
}

public void CourseUnits(String cName, String cNum){
courseUnitName = cName;
courseUnitNum = cNum;
courseUnitID = createCourseUnitID();
courseUnitArray.add(this);
}

private static int createCourseUnitID() {
++lastAssignedID;
return lastAssignedID;
}

public String courseUnitName () {
return this.courseUnitName;
}


public String courseUnitNum () {
return this.courseUnitNum;
}


public int courseUnitID () {
return this.courseUnitID;
}

public static void listCourseUnit(int idx){
CourseUnits holdCourseUnit = new CourseUnits();
holdCourseUnit = courseUnitArray.get(idx);
System.out.println(holdCourseUnit.courseUnitID + " " + holdCourseUnit.courseUnitName + " " + holdCourseUnit.courseUnitNum);
}

public static void listCourseUnitArray(){
CourseUnits holdCourseUnit = new CourseUnits();
for (int i=0; i < courseUnitArray.size(); i++){
holdCourseUnit = courseUnitArray.get(i);
System.out.println(holdCourseUnit.courseUnitID + " " + holdCourseUnit.courseUnitName + " " + holdCourseUnit.courseUnitNum);
}
}

public static int findCourseUnit(int inCourseUnitID){
CourseUnits holdCourseUnit = new CourseUnits();
for (int i=0; i < courseUnitArray.size(); i++){
holdCourseUnit = courseUnitArray.get(i);
if (inCourseUnitID == holdCourseUnit.courseUnitID())
return i;
}
return -1;
}

public static void deleteCourseUnit(int idx){
courseUnitArray.remove(idx);
}



private static BufferedReader stdin =
new BufferedReader( new InputStreamReader( System.in ) );

Scanner input = new Scanner( System.in );

public static void main(String[] args) throws IOException {

if (courseUnitArray.size() == 0)
System.out.println("There are no courses");
else
listCourseUnitArray();


String [] courseUnitNames = {"English 101", "Algebra 101","Biology 101","Geometry 101","Englis Literature"};
String [] courseUnitNums = {"E101","M101","Sci101","M102","E103"};

CourseUnits courseUnitArray[] = new CourseUnits[5];
CourseUnitArray[0] = new CourseUnits("name","num");

}
}


thanks.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 05-23-2008, 07:58 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 4,609
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Defining the constructor is wrong. There is no return type in constructor. Even no void there.

You have use the same name for ArrayList as well as object array. You should rename one of them.

Code:
import java.util.*; import java.io.*; import java.util.Scanner; public class CourseUnits { private Integer courseUnitID; private String courseUnitName; private String courseUnitNum; private static int lastAssignedID = 10000; //in the real world the ArrayList would not be used. Instead a datbase table would //be used. private static ArrayList<CourseUnits> courseUnitArray = new ArrayList<CourseUnits>(); //default constructor - no parameters public CourseUnits() { } public CourseUnits(String cName, String cNum){ courseUnitName = cName; courseUnitNum = cNum; courseUnitID = createCourseUnitID(); courseUnitArray.add(this); } private static int createCourseUnitID() { ++lastAssignedID; return lastAssignedID; } public String courseUnitName () { return this.courseUnitName; } public String courseUnitNum () { return this.courseUnitNum; } public int courseUnitID () { return this.courseUnitID; } public static void listCourseUnit(int idx){ CourseUnits holdCourseUnit = new CourseUnits(); holdCourseUnit = courseUnitArray.get(idx); System.out.println(holdCourseUnit.courseUnitID + " " + holdCourseUnit.courseUnitName + " " + holdCourseUnit.courseUnitNum); } public static void listCourseUnitArray(){ CourseUnits holdCourseUnit = new CourseUnits(); for (int i=0; i < courseUnitArray.size(); i++){ holdCourseUnit = courseUnitArray.get(i); System.out.println(holdCourseUnit.courseUnitID + " " + holdCourseUnit.courseUnitName + " " + holdCourseUnit.courseUnitNum); } } public static int findCourseUnit(int inCourseUnitID){ CourseUnits holdCourseUnit = new CourseUnits(); for (int i=0; i < courseUnitArray.size(); i++){ holdCourseUnit = courseUnitArray.get(i); if (inCourseUnitID == holdCourseUnit.courseUnitID()) return i; } return -1; } public static void deleteCourseUnit(int idx){ courseUnitArray.remove(idx); } private static BufferedReader stdin = new BufferedReader( new InputStreamReader( System.in ) ); Scanner input = new Scanner( System.in ); @SuppressWarnings("empty-statement") public static void main(String[] args) throws IOException { if (courseUnitArray.size() == 0) System.out.println("There are no courses"); else listCourseUnitArray(); String [] courseUnitNames = {"English 101", "Algebra 101","Biology 101","Geometry 101","Englis Literature"}; String [] courseUnitNums = {"E101","M101","Sci101","M102","E103"}; CourseUnits courseUnitArray2[] = new CourseUnits[5]; courseUnitArray2[0] = new CourseUnits("name", "num");; } }
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
JRE rtapplet class not found error avinash.natekar Java Applets 8 04-24-2008 05:25 AM
Error: cannot find symbol silvia New To Java 1 08-07-2007 07:39 AM
Error: cannot find symbol cachi AWT / Swing 1 08-06-2007 10:12 PM
Error: cannot resolve symbol, help me mathias Enterprise JavaBeans 1 08-06-2007 04:46 PM
Error: no class definition found toby New To Java 4 07-27-2007 09:01 PM


All times are GMT +3. The time now is 10:40 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org