Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / November 2006

Tip: Looking for answers? Try searching our database.

Why doesn't this very simple code snippet work?

Thread view: 
lbrtchx@hotmail.com - 30 Nov 2006 10:08 GMT
// - - - - - - - - - - - - - - - - code
import java.io.*;
import java.util.*;

// __
class ALS00{
protected int iLL;
ArrayList<String> ALS = null;
// __
LSet00(int iLL){
 if(iLL > -1){ this.iLL = iLL; ALS = new ArrayList<String>(); }
 else{}
}
// __
public boolean setNewS(String aS){
 boolean IsNw = ALS.contains(aS);
 if(!IsNw){
  int iSz = ALS.size(); ALS.add(aS); IsNw = ((ALS.size() - iSz) == 1);
 }
// __
 return(IsNw);
}
}
// __
public class ALS00Test{
public static void main(String[] aArgs){ ALS00 ALS = new ALS00(); }
}
// - - - - - - - - - - - - - - - -
.
It should based on:
.
http://java.sun.com/j2se/1.5.0/docs/api/java/util/ArrayList.html
.

// - - - - - - - - - - - - - - - - errors
sh-3.1# javac *.java
ALS00Test.java:7: <identifier> expected
ArrayList<String> ALS = null;
         ^
ALS00Test.java:9: invalid method declaration; return type required
LSet00(int iLL){
^
ALS00Test.java:12: '(' or '[' expected
  ALS = new ArrayList<String>();
                     ^
SlashDotCleaner04Test.java:7: <identifier> expected
HashSet<String> HSS;
       ^
SlashDotCleaner04Test.java:13: '(' or '[' expected
  HSS = new HashSet<String>();
                   ^
5 errors
// - - - - - - - - - - - - - - - -
Hendrik Maryns - 30 Nov 2006 10:23 GMT
lbrtchx@hotmail.com schreef:
> // - - - - - - - - - - - - - - - - code
> import java.io.*;
[quoted text clipped - 28 lines]
> .
>  http://java.sun.com/j2se/1.5.0/docs/api/java/util/ArrayList.html

First of: your style is terrible.  Please stick to the name and case
conventions.

> // - - - - - - - - - - - - - - - - errors
> sh-3.1# javac *.java
[quoted text clipped - 15 lines]
> 5 errors
> // - - - - - - - - - - - - - - - -

You need java 5.0 to compile this code.  It seems you are trying to
compile it with an old java.

H.
- --
Hendrik Maryns
http://tcl.sfs.uni-tuebingen.de/~hendrik/
==================
http://aouw.org
Ask smart questions, get good answers:
http://www.catb.org/~esr/faqs/smart-questions.html
lbrtchx@hotmail.com - 30 Nov 2006 19:50 GMT
> You need java 5.0 to compile this code ...
: Well, actually I was using jdk .5.X
.
lbrtchx
heysc0tt@gmail.com - 30 Nov 2006 20:43 GMT
Looks like the problem is your method LSet00 which should be defined as
"void LSet00(..."

After resolving the method definition problem I was able to compile and
run using version 1.5.0_09.

Scott

On Nov 30, 11:50 am, lbrt...@hotmail.com wrote:
> > You need java 5.0 to compile this code ... : Well, actually I was using jdk .5.X
> .
>  lbrtchx


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.