Easy Java Stuff

I have been programming for almost 2 years in Visual Basic. Reciently I have decided to learn Java because it can be in .html files and is able to run on many operating systems. I attempted to write a small program that would say “<-the mouse is here.” by the mouse pointer on the Java applet. I don’t see anything wrong with the code but I am sure there is. Here it is. (Im sure you will see a lot of dumb mistakes, remember, I am new to the Java language)

import java.awt.*;

/*Hopefully... this will use the mouse input info*/

public class MouseInput extends java.applet.Applet implements Runnable
	private int mouseXvar, mouseYvar;
	private boolean isactive;
	mouseXvar = 0;
	mouseYvar = 0;
	isactive = true;


	public void function_start()
			mouseXvar = getX()
			mouseYvar = getY()
	public void paint(Graphics g)
		g.drawString("<- the mouse is here.", mouseXvar, mouseYvar);
</pre><BR>Here are the errors I got.<BR>line 10:<identifier> expected.<BR>     mouseXvar = 0;<BR>(points to = )<BR><BR>Line 11:<identifier> expected.<BR>     mouseYvar = 0;<BR>(points to = )<BR><BR>Line 12:<identifier> expected.<BR>     isactive = true;<BR>(points to = )<BR><BR>Line 14: invalid method declaration; return type required.<BR>     function_start()<BR>(points to f)<BR><BR>Line 15: ';' expected<BR><BR>Also could you explain some of these lines of code, I have no idea what they do but they seem to be in every program.<BR><pre class="ip-ubbcode-code-pre">
public class MouseInput extends java.applet.Applet implements Runnable
</pre><BR><pre class="ip-ubbcode-code-pre">
public void paint(Graphics g)

And also, what does void and static mean??? :confused: < these faces are cool.

This is probably the wrong place - you should try comp.lang.java.

Applets are an odd way to learn Java - standalone programs are better [this is what I always use for tests].

Lines 10,11+12 lack types. For 10+11 you need “int” + for line 12 you want a “bool”. In Java when you declare a type you say “type name [= value];”.

Line 14 looks like a C prototype - you don’t have these except in Java interfaces.

Line 15 - most statements in Java end with a “;” especially single line statements. Those that don’t are normally block statements that end with a ‘}’.

public class X extends Y implements Z - in OO this is quite a complex statement to understand! You are saying that you inherit the properties and methods of X and implement all the functionality of Z.

public void paint(Graphics g) says that you know how to display yourself in a UI environment - another complex thing that is not essential to understand Java.

You need a good Java book - try “Thinking in Java” (Eckel) or “Just Java” (van der Linden) or the JavaSoft online Java tutorials.

Thanks for the fast and complete reply