java class reference problem - why?

Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved

Join Date: Oct 2009
Posts: 28
Reputation: moutanna is an unknown quantity at this point 
Solved Threads: 6
moutanna moutanna is offline Offline
Light Poster
 
0
  #11
Oct 16th, 2009
please what you mean by this declaration:
public class ValidRecords<Student>
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 19
Reputation: bentlogic is an unknown quantity at this point 
Solved Threads: 0
bentlogic bentlogic is offline Offline
Newbie Poster
 
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...
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 1,003
Reputation: JamesCherrill is just really nice JamesCherrill is just really nice JamesCherrill is just really nice JamesCherrill is just really nice JamesCherrill is just really nice 
Solved Threads: 149
JamesCherrill JamesCherrill is offline Offline
Veteran Poster
 
0
  #13
Oct 16th, 2009
It's the .class files that need to be in the Assignments dir; the source .java files' locations are irrelevant to this.
The classpath must point to the folder that contains the Assignments folder, NOT to the folder where the files are.
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 19
Reputation: bentlogic is an unknown quantity at this point 
Solved Threads: 0
bentlogic bentlogic is offline Offline
Newbie Poster
 
0
  #14
Oct 16th, 2009
yep, that's the case. I realize this but alas there's no change to my situation... the clocks ticking and I don't know which wire to cut, red or blue???

This really has to be simple surely, but what have I missed? Maybe I'll try another computer in case it's environmental (or just mental).
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 1,003
Reputation: JamesCherrill is just really nice JamesCherrill is just really nice JamesCherrill is just really nice JamesCherrill is just really nice JamesCherrill is just really nice 
Solved Threads: 149
JamesCherrill JamesCherrill is offline Offline
Veteran Poster
 
0
  #15
Oct 16th, 2009
Are you sure?
Originally Posted by bentlogic View Post
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
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.
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 19
Reputation: bentlogic is an unknown quantity at this point 
Solved Threads: 0
bentlogic bentlogic is offline Offline
Newbie Poster
 
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 );
^
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 19
Reputation: bentlogic is an unknown quantity at this point 
Solved Threads: 0
bentlogic bentlogic is offline Offline
Newbie Poster
 
0
  #17
Oct 16th, 2009
the whitespace in front of the ^ (caret) has been blown away by the formatter thingy on this site; oops!

so the caret in above post should go under the 'S' in Student after the new keyword. So the constructor bit NOT the first Student in front of the sCopy

Hope that's clear
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 4,244
Reputation: peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of 
Solved Threads: 492
Moderator
Featured Poster
peter_budo's Avatar
peter_budo peter_budo is offline Offline
Code tags enforcer
 
0
  #18
Oct 16th, 2009
Remove "<Student>" from ValidRecords class opening, problem solved...

  1. package Assignment;
  2.  
  3. import java.util.*;
  4. /**
  5.  *
  6.  * @author Nigel Novak
  7.  */
  8. public class ValidRecords {
  9.  
  10. // Class Fields and Constants Follow
  11. private ArrayList<Student> list;
  12. 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
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 19
Reputation: bentlogic is an unknown quantity at this point 
Solved Threads: 0
bentlogic bentlogic is offline Offline
Newbie Poster
 
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.
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 4,244
Reputation: peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of 
Solved Threads: 492
Moderator
Featured Poster
peter_budo's Avatar
peter_budo peter_budo is offline Offline
Code tags enforcer
 
-1
  #20
Oct 17th, 2009
Originally Posted by bentlogic View Post
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.
Nothing special, already another user questioned your use of class declaration placeholder.
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
Reply With Quote Quick reply to this message  
Reply

Tags
class, compile, java, reference, time

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for class, compile, java, reference, time
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC