Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

bobber205

macrumors 68020
Original poster
Nov 15, 2005
2,182
1
Oregon
I'm playing with Objects in an applet. It's going so far pretty smoothly.
But when I try to run my applet in an actualy browser, a weird error comes up!

Why is this? I do access a object called NightElf in my code, but I have uploaded NightElf.class to my server...

I'm mystified about what to do.

Code is the following.

Code:
// ObjectMaking.java
// Alex Wait (http://www.alexwait.com)
// December 9, 2005
// Purpose: To Play With Constructors

import java.awt.*;
import java.applet.*;


public class ObjectMaking extends Applet
{

public void init()
{
System.out.println("Initializing The Applet");
}

public void destroy()
{
System.out.println("Destroying My Little Applet");
}

public void start()
{

	NightElf[] elves;

	elves = new NightElf[5];

for (int i = 0; i < 4 ; i++)
{
	elves[i] = new NightElf("Custom Elf ");
	System.out.println(elves[i].returnName());
}
	elves[4] = new NightElf();

	System.out.println("Starting Applet!");
	System.out.println("Made Some Objects");
}

} // end of ObjectMaking.class







class NightElf 
{
	private String name;

NightElf()
{	
	name = "Default Night Elf"; //default name 
	fakePrint(this.name);
}

NightElf(String customName)
{
	name = customName;
}

static void fakePrint(String output)
{
	System.out.println(output);
}

public String returnName() 
{
	return name;
}


} //end of NightElf class


Thanks for any help.

You can find the apple here. http://www.alexwait.com/Java/ObjectMaking.html
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.