| | |
java class reference problem - why?
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
•
•
Join Date: Oct 2009
Posts: 19
Reputation:
Solved Threads: 0
0
#12 Oct 16th, 2009
This is a standard way of declaring a java class that implements 'generics' ( sun has a pdf you can download on generics... )
There is a load of stuff on the web about generics in java; we are expected to make use of generics in our programming course when generics make sense... In this case I am making the type ArrayList<Student> an arraylist that is only able to have Student class elements stored in it... type safety...
There is a load of stuff on the web about generics in java; we are expected to make use of generics in our programming course when generics make sense... In this case I am making the type ArrayList<Student> an arraylist that is only able to have Student class elements stored in it... type safety...
•
•
Join Date: Apr 2008
Posts: 1,003
Reputation:
Solved Threads: 149
0
#15 Oct 16th, 2009
Are you sure?
1. If the second compile always fails you cannot have a second .class file to put into the directory.
2. Thay already had that. What did you change?
3. This is wrong - the classpath must point to the folder that contains the "Assignment" folder that contains the class files. It's irrelevant where you out the source files.
•
•
•
•
1. i put both classes into a directory called Assignment
2. i changed the package declarations (in both files) to be "package Assignment;"
3. i changed the classpath to the absolute pathname where the source files are
2. Thay already had that. What did you change?
3. This is wrong - the classpath must point to the folder that contains the "Assignment" folder that contains the class files. It's irrelevant where you out the source files.
•
•
Join Date: Oct 2009
Posts: 19
Reputation:
Solved Threads: 0
0
#16 Oct 16th, 2009
yes, I can always get Student.java to compile producing a .class file. I have never been able to get ValidRecords.java to compile.
The classpath is correct and is C:\ST152-Warwick\Assignment currently; this is where the files reside (the 2 source files and the Student.class file)...
I have just tried on another computer with EXACTLY the same result.
public class ValidRecords<Student> {
I am wondering about the generic declaration for ValidRecords class but not sure about any of this... reason:
compiler throws-
ValidRecords.java:74: unexpected type
found : type parameter Student
required : class
Student sCopy = new Student( s1 );
^
The classpath is correct and is C:\ST152-Warwick\Assignment currently; this is where the files reside (the 2 source files and the Student.class file)...
I have just tried on another computer with EXACTLY the same result.
public class ValidRecords<Student> {
I am wondering about the generic declaration for ValidRecords class but not sure about any of this... reason:
compiler throws-
ValidRecords.java:74: unexpected type
found : type parameter Student
required : class
Student sCopy = new Student( s1 );
^
0
#18 Oct 16th, 2009
Remove "<Student>" from ValidRecords class opening, problem solved...
java Syntax (Toggle Plain Text)
package Assignment; import java.util.*; /** * * @author Nigel Novak */ public class ValidRecords { // Class Fields and Constants Follow private ArrayList<Student> list; private int sortOrder;
Last edited by peter_budo; Oct 16th, 2009 at 7:14 pm.
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
•
•
Join Date: Oct 2009
Posts: 19
Reputation:
Solved Threads: 0
0
#19 Oct 16th, 2009
[QUOTE=peter_budo;1017052]Remove "<Student>" from ValidRecords class opening, problem solved...
Peter that's Sensational!
was under the impression that i needed that for the generic stuff to work, i.e. ArrayList<Student> ...
Obviously I don't understand generics too well (what newbie does
)?
Is ArrayList<ClassName> or any valid var name placeholder a special case of generics? I understand the type safety side but why don't I need to make the class declaration with this generic placeholder present for compiler??
Anyway, thanks so much for your help. Really appreciated!
Also, interested in the LJC Undergrad website although down-under in Perth, Western Australia.
Peter that's Sensational!
was under the impression that i needed that for the generic stuff to work, i.e. ArrayList<Student> ...Obviously I don't understand generics too well (what newbie does
)?Is ArrayList<ClassName> or any valid var name placeholder a special case of generics? I understand the type safety side but why don't I need to make the class declaration with this generic placeholder present for compiler??
Anyway, thanks so much for your help. Really appreciated!
Also, interested in the LJC Undergrad website although down-under in Perth, Western Australia.
-1
#20 Oct 17th, 2009
•
•
•
•
Peter that's Sensational!
was under the impression that i needed that for the generic stuff to work, i.e. ArrayList<Student> ...
Obviously I don't understand generics too well (what newbie does)?
Is ArrayList<ClassName> or any valid var name placeholder a special case of generics? I understand the type safety side but why don't I need to make the class declaration with this generic placeholder present for compiler??
Anyway, thanks so much for your help. Really appreciated!
Also, interested in the LJC Undergrad website although down-under in Perth, Western Australia.
I guess your reference to Sun tutorial on generics in PDF format is to this article Generics in the Java Programming Language. It is my opinion that this is not well presented. Try to read SCJP Sun Certified Programmer for Java 6 Study Guide from chapter 7 and see if that makes more sense for you (definitely easier to read then my endless rumbling).
As for anything similar to Java user/meetup groups I'm member in London I did not found anything in your location through meetup site, however your best chance would be get in touch with Australia Java Champion Mike Cannon-Brookes and see if he is aware of any Java group in your area. Good luck
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
![]() |
Similar Threads
- Isn't java pass by reference? (Java)
- Basic Class Module Problem (Visual Basic 4 / 5 / 6)
- Need help understanding how to use Java for a class. (Java)
- call the constructor of java class from script (Shell Scripting)
- Book / Java Compmlete Reference (Java)
- Help with class methods (Java)
- class array problem! (C++)
- Basic help with Java class (Java)
- Confused writing a Java Class (Java)
Other Threads in the Java Forum
- Previous Thread: How to make Java Application to a Windows Service
- Next Thread: Java recursive binary tree
| Thread Tools | Search this Thread |
Tag cloud for class, compile, java, reference, time
.net ajax apple applet array automation binary browser c# c++ class classes click clock code compile compiler component convert date design development digit draw eclipse ee error errors event firefox format fractal function game google gui homework html ide image input int integer integration jar java javafx javascript jetbrains jmf jsp julia jvm lego linux loop method methods microsoft mysql netbeans newbie news object oop php problem program programming project python recursion reference return rsa scanner security sell set smart socket software sort string subclass sun swing test threads time tlapse tomcat tree trolltech ubuntu unix web websites windows wxwidgets







