Cannot reslove symbol class Date
I am trying to get a clock to show the time in my program. However, when I try to compile the program a "cannot resolve symbol class Date" error appears. I can't figure out where the problem in my program is. Here is my source code. I would appreciate any help.
import javax.swing.*;
import java.io.*;
import java.lang.*;
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
//import java.util.*;
import java.math.*;
public class store
public static void main(String[] args)
String dataInput;
dataInput = JOptionPane.showInputDialog(null, "Input item data: ");
JOptionPane.showMessageDialog(null, "" + dataInput);
EasyReader console = new EasyReader();
int i, j, k, inum, icom, min, nswaps; inum = 0; boolean swap = false;
double num[] = new double[100]; double dsum, T;
do
System.out.println(); System.out.println("Command Menu"); System.out.println();
System.out.println("1 = Display the data");
System.out.println("2 = Bubble Sort the numbers");
System.out.println("3 = Selection Sort the numbers");
System.out.println("4 = Insertion Sort the numbers");
System.out.println("5 = Binary Search for a number");
System.out.println("0 = Exit the program"); System.out.println();
System.out.print("Enter Command - ");
icom = console.readInt(); System.out.println();
switch (icom)
case 1: // Display the data
Display(inum, num);
break;
case 2: // Bubble sort
nswaps = 0;
for (i = 0; i < (inum-1); i++ )
for (j = (i+1); j < inum; j++)
if (num[i] > num[j])
T = num;
num[i] = num[j];
num[j] = T;
nswaps++;
System.out.println("The number of swaps was - " + nswaps);
Display(inum, num);
break;
case 3: // Selection sort
nswaps = 0;
for (i = 0; i < inum - 1; i++) {
min = i; swap = false;
for (j = i + 1; j < inum; j++)
if (num[j] < num[min]) { min = j; swap = true; }
if (swap) {T = num[min];
num[min] = num[i];
num[i] = T;
nswaps++;}
System.out.println("The number of swaps was - " + nswaps);
Display(inum, num);
break;
case 4: // Selection sort
nswaps = 0;
for (i = 1; i < inum; i++)
j = i; T = num[i];
while ((j > 0) && (T < num[j-1]))
num[j] = num[j-1]; j--; nswaps++;
num[j] = T; nswaps++;
System.out.println("The number of swaps was - " + nswaps);
Display(inum, num);
break;
case 5: // Binary Search
System.out.println("Your numbers will be sorted first");
System.out.println();
for (i = 1; i < inum; i++)
j = i; T = num[i];
while ((j > 0) && (T < num[j-1]))
num[j] = num[j-1]; j--;
num[j] = T;
System.out.print("Enter the number to locate - ");
T = console.readDouble(); nswaps = 0; System.out.println();
int left = 0, right = inum, middle; k = -1;
while (left <= right)
middle = (left + right) / 2;
if (T > num[middle]) {left = middle + 1; nswaps++;}
else if (T < num[middle]) {right = middle - 1; nswaps++;}
else { k = middle; break; }
if (k == -1) System.out.println("Your number was not located in the array");
else System.out.println("Your number " + T + " is in position " + (k+1));
System.out.println();
System.out.println(nswaps + " comparisons were needed to search for your number");
Display(inum, num);
break;
} while (icom != 0);
public static void Display(int inum, double num[])
{ int k;
System.out.println();
System.out.println("");
System.out.println();
for (k = 0; k < inum; k++)
System.out.println((k+1) + " - " + num[k]);
return;
class Clock extends Thread
//A Canvas that will display the current time on the calculator
Canvas Time;
//A Date object that will access the current time
private Date now;
//A string to hold the current time
private String currentTime;
//The constructor for Clock, accepting a Label as an argument
public Clock(Canvas _Time)
Time = Time; //Time is passed by reference, so Time
//now refers to the same Canvas
start(); //start this thread
//The overriden run method of this thread
public void run()
//while this thread exists
while (true)
try
draw_clock(); //calls the draw_clock method
sleep(1000); //puts this thread to sleep for one
//second
//catches an InterruptedException that the sleep() method might throw
catch (InterruptedException e) { suspend(); }
//catches a NullPointerException and suspends the thread if one occurs
catch (NullPointerException e) { suspend(); }
//A method to draw the current time onto the Time Canvas on the applet
public void draw_clock()
try
//Obtains the Graphics object from the Canvas Time so that it can
//be manipulated directly
Graphics g = Time.getGraphics();
g.setColor(Color.gray); //sets the color of the Graphics object
//to gray for the rectangle background
g.fillRect(0,0,165,25); //fills the Canvas area with a rectangle
//starting at 0,0 coordinates of the Canvas
//and extending to the length and width
g.setColor(Color.orange); //sets the color of the Graphics object
//to orange for the text color
get_the_time(); //calls the get_the_time() method
//calls the drawString method of the Graphics object g, which will
//draw a string to the screen
//Accepts a string and two integers to represent the coordinates
g.drawString("Current Time - " + currentTime, 0, 17);
//catches a NullPointerException and suspends the thread if one occurs
catch (NullPointerException e) { suspend(); }
//A method to obtain the current time, accurate to the second
public void get_the_time()
//creates a new Date object for "now" every time this is called
now = new Date( );
//integers to hold the hours, minutes and seconds of the current time
int a = now.getHours();
int b = now.getMinutes();
int c = now.getSeconds();
if (a == 0) a = 12; //if hours are zero, set them to twelve
if (a > 12) a = a -12; //if hours are greater than twelve, make a
//conversion to civilian time, as opposed to
//24-hour time
if ( a < 10) //if hours are less than 10
//sets the currentTime string to 0, appends a's value and a
//colon
currentTime = "0" + a + ":" ;
else
//otherwise set currentTime string to "a", append a colon
currentTime = a +":";
if (b < 10) //if minutes are less than ten
//append a zero to string currentTime, then append "b" and a colon
currentTime = currentTime + "0" + b + ":" ;
else
//otherwise append "b" and a colon to currentTime string
currentTime = currentTime + b + ":" ;
if (c < 10) //if seconds are less than ten
//append a zero to string currentTime, then append "c" and a colon
currentTime = currentTime + "0" + c ;
else
//otherwise append "c" to currentTime string
currentTime = currentTime + c;
} //end of the Clock class
Wow.
1) Please in future use the code tags to format code you post so that it doesn't think you have italics in your code and render it largely1 unreadable. Read this
http://forum.java.sun.com/help.jspa?sec=formatting
2) You commented out the import of java.util which is the problem you are complaining about.
3) Are you planning to stick all the code you ever write into the one source file? Why is all this stuff rammed together. Yoinks.
Similar Messages
-
Cannot find symbol - class whatever ... Arraylists!
Hi all,
Having a problem creating an Arraylist. Firstly, I thought you could have an ArrayList of what ever you wanted. For example, private ArrayList<Anything> myarraylist... that would be an ArrayList of "anything".
I'm trying to create an ArrayList to store locations. However, these locations are stored inside the objects of another class (as a field).
When I go to do private ArrayList<Locations> it says it cannot find symbol - class locations. Obviously it's looking for a class that doesn't exist. How would I store the locations of rallies into the collection, that are stored inside the object of another class (i.e. a RoadTrip object which has details of dates, location, codes etc).
Hope you can understand that...!
CheersYou can create as many RoadTrip ArrayLists as you want, as long as the variables that point to the ArrayLists have unique names.
ArrayList<RoadTrip> al1 = new ArrayList<RoadTrip>();
ArrayList<RoadTrip> al2 = new ArrayList<RoadTrip>();Nothing wrong with that. -
PLEASE HELP: cannot resolve symbol class
it's showing me the error on the following lines 7 and 9
it says cannot resolve symbol class Name and cannot resolve symbol class Phone
I also have a package name addressBook and it contains two files Entry.java and Address.java
Here is the code:
import java.io.*;
import addressBook.*;
public class AddressDr
public static void main(String[] args)throws IOException
Name name;
Address address;
Phone phone;
Entry entry;
String first, last, middle, street, city, state, zip;
int areaCode, number;
BufferedReader in;
in=new BufferedReader(new InputStreamReader(System.in));
PrintWriter outFile;
outFile=new PrintWriter(new FileWriter("Entries"));
System.out.println("Quit entered fot the first name ends the " + "application.");
System.out.print("Enter first name: ");
first=in.readLine();
while (first.compareTo("Quit") !=0)
System.out.print("Enter last name: ");
last=in.readLine();
System.out.print("Enter middle name: ");
middle=in.readLine();
name=new Name(first, last, middle);
System.out.print("Enter street address: ");
street=in.readLine();
System.out.print("Enter city: ");
city=in.readLine();
System.out.print("Enter state: ");
state=in.readLine();
System.out.print("Enter ZIP code: ");
zip=in.readLine();
address=new Address(street, city, state, zip);
System.out.print("Enter areaCode: ");
areaCode = Integer.parseInt(in.readLine());
System.out.print("Enter number: ");
number=Integer.parseInt(in.readLine());
phone=new Phone(areaCode, number);
entry= new Entry(name, address, phone);
entry.writeToFile(outFile);
System.out.print("Enter first name: ");
first=in.readLine();
outFile.close();
}OK. Here is how I did it.
I have AddressDr which is Address driver.
I have two files Address and Entry which in package addressBook.
AddressDr:
import java.io.*;
import addressBook.*;
public class AddressDr
public static void main(String[] args)throws IOException
Name name;
Address address;
Phone phone;
Entry entry;
String first, last, middle, street, city, state, zip;
int areaCode, number;
BufferedReader in;
in=new BufferedReader(new InputStreamReader(System.in));
PrintWriter outFile;
outFile=new PrintWriter(new FileWriter("Entries"));
System.out.println("Quit entered fot the first name ends the " + "application.");
System.out.print("Enter first name: ");
first=in.readLine();
while (first.compareTo("Quit") !=0)
System.out.print("Enter last name: ");
last=in.readLine();
System.out.print("Enter middle name: ");
middle=in.readLine();
name=new Name(first, last, middle);
System.out.print("Enter street address: ");
street=in.readLine();
System.out.print("Enter city: ");
city=in.readLine();
System.out.print("Enter state: ");
state=in.readLine();
System.out.print("Enter ZIP code: ");
zip=in.readLine();
address=new Address(street, city, state, zip);
System.out.print("Enter areaCode: ");
areaCode = Integer.parseInt(in.readLine());
System.out.print("Enter number: ");
number=Integer.parseInt(in.readLine());
phone=new Phone(areaCode, number);
entry= new Entry(name, address, phone);
entry.writeToFile(outFile);
System.out.print("Enter first name: ");
first=in.readLine();
outFile.close();
Entry:
package addressBook;
import java.io.*;
public class Entry
Name name;
Address address;
Phone phone;
public Entry(Name newName, Address newAddress, Phone phoneNumber)
name = newName;
address = newAddress;
phone = phoneNumber;
public Name knowName()
return name;
public Address knowAddress()
return address;
public Phone knowPhone()
return phone;
public void writeToFile(PrintWriter outFile)
outFile.println(name.knowFirstName());
outFile.println(name.knowLastName());
outFile.println(name.knowMiddleName());
oufFile.println(address.knowStreet());
outFile.println(address.knowState());
outFile.println(address.knowCity());
outFile.println(address.knowZip());
outFile.println(phone.knowAreaCode());
outFile.println(phone.knowDigits());
Address:
package addressBook;
public class Address
String street;
String city;
String state;
String zipCode;
public Address(String newStreet, String newCity, String newState, String zip)
street=newStreet;
city=newCity;
state=newState;
zipCode=zip;
public String knowStreet()
return street;
public String knowCity()
return city;
public String knowState()
return state;
public String knowZip()
return zipCode;
} -
Cannot find symbol class Scanner
hi all
i'm defining a class within a project so i can use the class inside my program, but the line:
Scanner keyboard = new Scanner(System.in);generates an error with my compiler:
cannot find symbol class Scanner
please helpyou aren't using jdk 5 or higher then. that's when scanner was added to the jdk.
download a modern jdk and you'll be fine.
% -
Cannot find symbol class Usernamebean
hi i am new in j2ee
can some body help to give the solution.
i am always thankfull to everybody
i have a servlet where i am calling a bean of same package but servlet not compile giving that error
cannot find symbol class Usernamebean
servlet code
package ecomm; import java.sql.*; import javax.servlet.*; import javax.servlet.http.*; import java.io.*; import java.util.*; import bengalcom.*; public class Loginservelet extends HttpServlet { public void doGet(HttpServletRequest req,HttpServletResponse res) throws ServletException,IOException { try { String accnum=req.getParameter("username"); String pinnum=req.getParameter("password"); try { Class.forName("com.mysql.jdbc.Driver"); Connection dbcon=DriverManager.getConnection("jdbc:mysql://localhost/ecomm","root",""); PreparedStatement s = dbcon.prepareStatement("select * from vendordetails where email = ? and password = ? and blocking='No' "); s.setString(1,accnum); s.setString(2,pinnum); ResultSet result=s.executeQuery(); boolean rowfound=false; rowfound=result.next(); if(rowfound==true) { String vname=result.getString("fname"); String vid=result.getString("vid"); String email=result.getString("email"); UsernameBean nameBean =new UsernameBean(); nameBean.setFirstName(accnum); HttpSession session = req.getSession(true); session.setAttribute("vname",vname); session.setAttribute("vid",vid); session.setAttribute("email",email); RequestDispatcher dispatcher=getServletContext().getRequestDispatcher("/earea.jsp?vname=vname&vid=vid&email=email"); dispatcher.forward(req,res); dbcon.close(); } else{ RequestDispatcher dispatcher=getServletContext().getRequestDispatcher("/eblock.jsp"); dispatcher.forward(req,res); } } catch(ClassNotFoundException e) { } } catch(SQLException e) { System.out.println(e.toString()); } } public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { doGet(req, res); } }Hi,
java is case sensitive, Check the case in class name.
Regards,
Ram -
Cannot resolve symbol class graphics
does anyone know what the error
cannot resolve symbol class graphics means?
with this code i can't seem to call the graphics method to draw the line....any reason why?
import javax.swing.*;
import java.*;
public class LineDraw extends JFrame {
public static void main(String[] args) {
LineDraw ld = new LineDraw();
ld.setSize(500,500);
ld.setVisible(true);
ld.enterVariables();
public void init(){
private int x1;
private int x2;
private int y1;
private int y2;
public void paint(Graphics g) {
g.GetGraphics(g);
super.paintComponent(g);
g.drawLine(x1, y1, x2, y2);
public void enterVariables() {
x1 = Integer.parseInt(JOptionPane.showInputDialog("Enter x1:"));
y1 = Integer.parseInt(JOptionPane.showInputDialog("Enter y1:"));
x2 = Integer.parseInt(JOptionPane.showInputDialog("Enter x2:"));
y2 = Integer.parseInt(JOptionPane.showInputDialog("Enter y2:"));
repaint();
}well the exact error message is ...by the way now that i think about it
if the graphics method shoudl not be part of the JFrame class then what method would i use to draw 2D Graphics?
--------------------Configuration: <Default>--------------------
C:\Documents and Settings\c1s5\My Documents\LineDraw.java:21: cannot resolve symbol
symbol : class Graphics
location: class LineDraw
public void paint(Graphics g)
^
1 error
Process completed.
and the exact code is
import javax.swing.*;
import java.*;
public class LineDraw extends JFrame {
public static void main(String[] args) {
LineDraw ld = new LineDraw();
ld.setSize(1024,500);
ld.setVisible(true);
ld.enterVariables();
private int x1;
private int x2;
private int y1;
private int y2;
public void paint(Graphics g)
super.paintComponent(g);
g.drawLine(x1, y1, x2, y2);
public void enterVariables() {
x1 = Integer.parseInt(JOptionPane.showInputDialog("Enter x1:"));
y1 = Integer.parseInt(JOptionPane.showInputDialog("Enter y1:"));
x2 = Integer.parseInt(JOptionPane.showInputDialog("Enter x2:"));
y2 = Integer.parseInt(JOptionPane.showInputDialog("Enter y2:"));
repaint();
} -
"cannot find symbol : class Scanner" error message
I have an error message that says:
"cannot find symbol : class Scanner"
I tried typing at the top of the program
import java.util.Scanner;but I still have the same error message.
What should I do ?
Thank you in advancehttp://java.sun.com/j2se/1.5.0/docs/api/java/util/Scanner.html
Since:
1.5
look at the javadoc, it says since 1.5 so it's not there in earlier versions.
just a guess -
Cannot resolve symbol class Scanner (Error)
For whatever reason I get the error message "cannot resolve symbol class Scanner" when trying to run this:
import java.io.*;
import java.util.*;
public class NameReversal
public static void main(String args[])
System.out.print("Enter your name: ");
Scanner Reader = new Scanner(System.in);
String first = Reader.next();
String finl = Reader.next();
int z = first.length();
int v = finl.length();
int y = z-1;
int f = y-1;
for(int i = y; i>=0; z--)
System.out.print(first.charAt(1));
System.out.print(" ");
for(int p = f; p >= 0; p--)
System.out.println(finl.charAt(p));
}The Scanner class is in the JDK version 1.5 or later. You must be using an earlier version.
-
"cannot find symbol class studentList" error
Hi I get this error
"cannot find symbol class studentList", but this class is at the same file and also it is in the same folder. so what's wrong .. and I checked the spelling it's the same.
I should create an object named myList of type studentList
and second, I call method menu() and pass it myList as actual parameter.
so I called the function menu which is should be in the main too
like this
myList.menu();
and menu method accepts as parameter an object of type studentList. and display the menu for the user to choose..
here is part my program:
public class ListTest
{ public void menu(Student L) // accepts parameter
System.out.println("");
System.out.println("Choose a number between 1 to 4");
System.out.println("1-Print Info of A Student ");
System.out.println("2-Print Info of All Students ");
System.out.println("3-Display grade of A Specific student");
System.out.println("4-Exit");
System.out.println("");
int choice = Stdin.readInteger();
while (choice != 5)
switch (choice) {
case 1:
L.PrintAStudent(int L);
break;
case 2:
L.PrintAll();
break;
case 3:
L.DisplayGPA();
break;
case 3:
System.exit(0);
break;
default:
System.out.println("wrong Number");
System.out.println("Enter a number between 1 to 4 ");
System.out.println("Enter 4 to Exit");
break;
System.out.println("");
System.out.println("Choose a number between 1 to 4");
System.out.println("1-Print Info of A Student ");
System.out.println("2-Print Info of All Students ");
System.out.println("3-Display grade of A Specific student");
System.out.println("4-Exit");
System.out.println("");
choice = Stdin.readInteger();
}// end method menu
public static void main(String args[ ])
{ studentList myList = new studentList();//myList object is created
myList.menu();
}//end main
}// end of class ListTest
you have mentioned about the class "studentList" but that class is not to be found in the code you have pasted. its instead "ListTest". And the "menu" function seems to b a part of "ListTest" class. Can you provide the structure of the classes "studentList" and "Student" so that the problem can be more clearly understood?
also you are using the variable "Stdin" in the line int choice = Stdin.readInteger(); where as you have not declared this variable.
in the "switch" statement you are calling two different functions for the same case "3" where as it should be "case 3" and "case 4" respectively.
in the "main" you are calling the "menu" function without any parameter while you actually want to pass argument of type "studentList". -
Cannot find symbol class ParseException
I have this in my code how ever
DateFormat formatter = new SimpleDateFormat("ddMMyyyy");
dDateStamp = (Date)formatter.parse(dateStamp);
When I pass in say
dateStamp=safsadssad sa;
I get an error which is fine.
I can not seem to catch this error with try catch
When I use the one below it says it cannot find the symbol
When i use the Exception it still throws and error to jsp page
cannot find symbol
symbol : class ParseException
}catch(ParseException e){
symbol : class ParseException
}catch(ParseException e){
Any One know I csn trap this?
Thanks in advanceWell, it's in the j2se API. Not sure what to tell you...
-
I am having a "Cannot find symbol" problem. My Java is a bit rusty so I'm not exactly sure what it could be. I have two classes, City and SisterCities. The SisterCities references the City class. The City class compiles fine. Both classes are part of the same package. However, when I compile SisterCities, I get the error. Could you please tell me how to get the second class to recognize the first (import, extends, not really sure. I've tried alot) Here are those two classes so far...
****** City ********
package hw01;
public class City
public final String name;
public final String country;
public final City [] sisters;
public City (String name, String country)
// throw new RuntimeException ("Not implemented yet.");
this.name = name;
this.country = country;
this.sisters = new City [0];
public City (String name, String country, City [] sisters)
// throw new RuntimeException ("Not implemented yet.");
this.name = name;
this.country = country;
this.sisters = new City [sisters.length];
for (int i = 0; i < sisters.length; i++) {
this.sisters[i] = sisters;
public void setSisters (City [] sisters)
// throw new RuntimeException ("Not implemented yet.");
for (int i = 0; i < sisters.length; i++) {
this.sisters[i] = sisters[i];
public String getName ()
// throw new RuntimeException ("Not implemented yet.");
return this.name;
public String getCountry ()
// throw new RuntimeException ("Not implemented yet.");
return this.country;
public City [] getSisters ()
// throw new RuntimeException ("Not implemented yet.");
return this.sisters;
******** SisterCities *********
package hw01;
import java.util.LinkedList;
public class SisterCities
public final LinkedList cityList;
public SisterCities ()
// throw new RuntimeException ("Not implemented yet.");
public void addCity (City city)
// throw new RuntimeException ("Not implemented yet.");
this.cityList.add(city);
public int getNumCities ()
// throw new RuntimeException ("Not implemented yet.");
public City getCity (int i)
// throw new RuntimeException ("Not implemented yet.");final attribute members like "cityList" must be initialised when they're declared or inside the constructors
if you want to compile, you'll also have to uncomment the "throws" in your methods (or return a value)
(pay attention to the error messages the compiler gives you and paste them all when posting questions) -
Cannot resolve symbol: class OracleDriver
Attempting to compile a servlet on Apache Server using same jdeveloper jdbc libraries:
classes12.jar & nls_charset12.jar
Error message:
$compilejava2.sh ProdJobs
ProdJobs.java:361: cannot resolve symbol
symbol : class OracleDriver
location: package driver
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
Am I missing something else?
JeffreyEnter this code into your program and then put the Oracle jar file that contains the driver in your run-time classpath.
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
catch(ClassNotFoundException cnfe) {
// driver not found
}The effect of this is that the classloader will load the Oracle driver for you then call it's static initiailizer that does a bunch of magic that results in the Java runtime knowing that there's a JDBC driver out there.
It is a little weird - but that's the way it works. -
Cannot resolve symbol: class EJBObject
Using javac I get this compile error on this file Calculator.java
Calculator.java:1: cannot resolve symbol
symbol : class EJBObject
location: package ejb
import javax.ejb.EJBObject;
^
Calculator.java:5: cannot resolve symbol
symbol : class EJBObject
location: interface Calculator
public interface Calculator extends EJBObject {
Source code for Calculator.java
import javax.ejb.EJBObject;
import java.rmi.*;
public interface Calculator extends EJBObject {
public long add (int x, int y) throws RemoteException;
public long subtract (int x, int y) throws RemoteException;This code is from a book, so I will assume its a classpath problem. My
classpath looks like:
"C\QTJava.zip".;%J2EE_HOME%\lib\j2ee.jar;%J2EE_HOME%\lib\locale
Also the following enviorment varibales have been set to:
J2EE_HOME
C:\Development\Java\j2sdkee1.3.1
JAVA_HOME
C:\Development\Java\jdk1.3.1
Path
%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files\Common Files\Adaptec Shared\System;%JAVA_HOME%\bin;%J2EE_HOME%\bin
I can run j2EE, like "j2EE -verbose" (no problems)
also run cloudscape, like "cloudscape -start" (no problems)
also can run deploytool, like "deploytool" (no problems, & deploy sample ear files from cd book)
Your help is appreicated. -
Cannot find symbol class entry
.\ListGraph.java:26: cannot find symbol
symbol : class Entry
location: class Map
for(Map.Entry<Stad,List<ListEdge>> me : nodes.entrySet())
^
1 error
this is what i get when i try to compile this code, its the lowest part thats getting errors:
import java.util.*;
import java.util.Map.*;
import java.util.Map.Entry;
class ListGraph{
private HashMap<Stad,List<ListEdge>> nodes =
new HashMap<Stad,List<ListEdge>>();
public void addNode(Stad ny){
nodes.put(ny, new ArrayList<ListEdge>());
public void connect(Stad from, Stad to, String n, int v){
List<ListEdge> fromList = nodes.get(from);
List<ListEdge> toList = nodes.get(to);
ListEdge e1 = new ListEdge(to, n, v);
fromList.add(e1);
ListEdge e2 = new ListEdge(from, n, v);
toList.add(e2);
public String toString(){
String ret = "";
for(Map.Entry<Stad,List<ListEdge>> me : nodes.entrySet())
ret += me.getKey()+": "+me.getValue()+"\n";
return ret;
}Bananen123 wrote:
.\ListGraph.java:26: cannot find symbol
symbol : class Entry
location: class MapI don't get the same error, so I'm not sure what code you are actually trying to compile. Do you happen to have defined another class named Map in the default package?
Also, please use code tags when posting code. Example: import java.util.*;
import java.util.Map.*;
import java.util.Map.Entry;
class ListGraph{
private HashMap<Stad,List<ListEdge>> nodes =
new HashMap<Stad,List<ListEdge>>();
public void addNode(Stad ny){
nodes.put(ny, new ArrayList<ListEdge>());
public void connect(Stad from, Stad to, String n, int v){
List<ListEdge> fromList = nodes.get(from);
List<ListEdge> toList = nodes.get(to);
ListEdge e1 = new ListEdge(to, n, v);
fromList.add(e1);
ListEdge e2 = new ListEdge(from, n, v);
toList.add(e2);
public String toString(){
String ret = "";
for(Map.Entry<Stad,List<ListEdge>> me : nodes.entrySet())
ret += me.getKey()+": "+me.getValue()+"\n";
return ret;
class Stad {}
class ListEdge{ ListEdge(Stad s, String str, int i) {} }~ -
Cannot find symbol : class ! problem
Hello,
I have 2 java files (CD.java & CDCatalog.java) in a package called "testPackage". I can compile CD.java, but CDCatalog.java (that creates CD instances) gives following error - cannot find symbol symbol : class CD
Below are the 2 files, please tell me why I get this errors , thanks!
1) CDCatalog.java
package testPackages;
import java.util.Hashtable;
//import testPackages.CD;
public class CDCatalog {
/** The CDs, by title */
private Hashtable catalog;
public CDCatalog( ) {
catalog = new Hashtable( );
// Seed the catalog
addCD(new CD("Nickel Creek", "Nickel Creek", "Sugar Hill"));
addCD(new CD("Let it Fall", "Sean Watkins", "Sugar Hill"));
addCD(new CD("Aerial Boundaries", "Michael Hedges", "Windham Hill"));
addCD(new CD("Taproot", "Michael Hedges", "Windham Hill"));
public void addCD(CD cd) {
if (cd == null) {
throw new IllegalArgumentException("The CD object cannot be null.");
catalog.put(cd.getTitle( ), cd);
2) CD.java
package testPackages;
public class CD {
private String title;
private String artist;
private String label;
public CD( ) {
// Default constructor
public CD(String title, String artist, String label) {
this.title = title;
this.artist = artist;
this.label = label;
public String getTitle( ) {
return title;
public void setTitle(String title) {
this.title = title;
public String getArtist( ) {
return artist;
public void setArtist(String artist) {
this.artist = artist;
public String getLabel( ) {
return label;
public void setLabel(String label) {
this.label = label;
public String toString( ) {
return "'" + title + "' by " + artist + ", on " +
label;
}just tried it as well, no problems, provided you
compile CD.java firstI just tried from the shell ans look at this...
E:\testPackages>dir
Volume in drive E is MYFLASHDISK
Volume Serial Number is 483B-B160
Directory of E:\testPackages
05/24/2006 07:48 PM <DIR> .
05/24/2006 07:48 PM <DIR> ..
05/24/2006 07:20 PM 1,143 CD.java
05/24/2006 07:50 PM 1,053 CD.class
05/24/2006 07:56 PM 972 CDCatalog.java
3 File(s) 3,168 bytes
2 Dir(s) 1,024,503,808 bytes free
E:\testPackages>javac -cp e:\testPackages CDCatalog.java
CDCatalog.java:30: cannot find symbol
symbol : class CD
location: class testPackages.CDCatalog
public void addCD(CD cd) {
^
CDCatalog.java:24: cannot find symbol
symbol : class CD
location: class testPackages.CDCatalog
addCD(new CD("Nickel Creek", "Nickel Creek", "Sugar Hill"));
^
CDCatalog.java:25: cannot find symbol
symbol : class CD
location: class testPackages.CDCatalog
addCD(new CD("Let it Fall", "Sean Watkins", "Sugar Hill"));
^
CDCatalog.java:26: cannot find symbol
symbol : class CD
location: class testPackages.CDCatalog
addCD(new CD("Aerial Boundaries", "Michael Hedges", "Windham Hill"));
^
CDCatalog.java:27: cannot find symbol
symbol : class CD
location: class testPackages.CDCatalog
addCD(new CD("Taproot", "Michael Hedges", "Windham Hill"));
^
5 errors
E:\testPackages>I am now officially confused. I even specified the exact path to the CD.class file and javac still didnt like it.
I'll dig some more. It has to be related to the classpath some how..
JJ
Still Stumped.. I'll sleep on it..
Message was edited by:
Java_Jay
Maybe you are looking for
-
I want to order a second copy of an existing iPhoto book. Though created in the smaller format now only the larger format is showing. How can I switch an existing iPhoto book back to the smaller format?
-
How can I stop iTunes from grabbing the CD drive?
I want to use cdparanoia as my ripper but iTunes keeps automounting the drive when cdparanoia gets a couple of sectors in, even if I disable disk level automounting e.g. diskarbitration and friends. I conclude it must be happening at application leve
-
IPhone to iPhone iMessage not working
So my boyfriend recently got an iPhone and a new number so I put his new number in my contact as an iPhone number. Well, when I text him it says that he sent an iMessage but mine says text message. I don't know how to fix it. Please help, thank you!
-
Iphoto 6.6 suddenly cannot see my photo library content
I have about 1000 images in my library. One day it asked me to update the cache or something like that. I've done this many times before and it was never a problem, however, this time it came back wtih only 73 files in the library. When I check my ha
-
DVD Burning takes so long, first time around - why?
Hi guys, I wonder if anyone can help with a query I have please? I use an external DVD burner to burn DVD's for a customer each day (http://eshop.macsales.com/item/OWC/MRF82SD22/). The interface I'm using on this particular burner, is the FW800 inter