CS 596 Java Programming Fall Semester, 1998 Using New Features |
||
---|---|---|
© 1998, All Rights Reserved, SDSU & Roger Whitney San Diego State University -- This page last updated 10-Oct-98 |
Using Language Features for the First Time
Rule 1
In a separate program, test the language feature using the smallest possible program. Do this before using the feature in a "real" program.
Motivation
package whitney; public class Sample { public void print() { System.out.println( "In foo"); } }In file: ~masc01146/Test.java
import whitney.Sample; class Test { public static void main( String[] args ){ Sample aTest = new Sample(); aTest.print(); }Set classpath:
setenv CLASSPATH '.:/home/ma/cs596/masc01146'
Using Language Features for the First Time Rule 2
Actual use Rule 1. It will save you time.
Rule 3
First get something working, then try one variation at a time.
Using Tech Support (or Instructors, TAs)
Tech support people (& instructors, TAs) are not mind readers nor do they have any supernatural powers.
You need to provide them with your problem and the relevant information in short message
Example Message 1 "I am having problems with packages. I followed your example. It does not work for me. My classes worked before I added the packages. What am I doing wrong?
Example 2 I am having problems with packages. In file: ~masc01146/whitney/Sample.java I have
package whitney; class Sample { public void print() { System.out.println( "In foo"); } }In file: ~masc01146/ whitney/Test.java
import whitney.*; class Test { public static void main( String[] args ){ Sample aTest = new Sample(); aTest.print(); }I set classpath by:
setenv CLASSPATH '.'
I then compile Test using:
javac Test.javaI then get the following error message:
Can't access class whitney.Sample. Class or interface must be public, in same package, or an accessible member class. classNotes.java line 5 Sample aTest = new Sample();
Copyright © 1998 SDSU & Roger Whitney, 5500 Campanile Drive, San Diego, CA 92182-7700 USA.
All rights reserved.
visitors since 05-Oct-98