Beginner Java help.
Okay, anyone know if there is a difference in Syntax between 1.02 and 1.5.0_7?
Reason, I've transcribe this code from a book and am getting odd errors of;
C:\Prog\Java\Day 14\ButtonLink.java:43:'class' or'interface' expected
import java.net.URL;
^
C:\Prog\Java\Day 14\ButtonLink.java:44:'class' or'interface' expected
import java.net.MalformedURLException;
^
2 errors
Tool completed with exit code 1
Code:
// ButtonLink.java starts here
import java.awt.*;
import java.net.*;
publicclass ButtonLinkextends java.applet.Applet{
Bookmark bmlist[] =new Bookmark[3];
publicvoid init(){
bmlist[0] =new Bookmark("Laura's",
"http://www.lne.com/lemay/");
bmlist[1]=new Bookmark("Gamelan",
"http://www.gamelan.com");
bmlist[2]=new Bookmark("Java Home Page",
"http://javasun.com");
setLayout(new GridLayout(bmlist.length, 1,10,10));
for(int i=0;i<bmlist.length; i++);{
add(new Button(bmlist[i].name));
}
}
publicboolean action(Event evt, Object arg){
if (evt.targetinstanceof Button){
Linkto((String)arg);
returntrue;
}elsereturnfalse;
}
void Linkto(String name){
URL theURL =null;
for(int i=0;i<bmlist.length;i++);{
if(name.equals(bmlist[i].name))
theURL = bmlist[i].url;
}
if(theURL !=null)
getAppletContext().showDocument(theURL);
}
}//ends Buttonlink.java
// starts Bookmark.java
import java.net.URL;
import java.net.MalformedURLException;
class Bookmark{
String name;
URL url;
Bookmark(String name, String theURL){
this.name = name;
try{this.url =new URL(theURL);}
catch(MalformedURLException e){
System.out.println("Bad URL: " + theURL);
}
}
}// bookmark ends
I'm teaching myself java, so any and all help's appreciated
THANKS
Message was edited by:
Patonb>

