Jump to content

Recommended Posts

Posted

I must be losing it. Every time I try to compile this simple program it is giving me a "illegal start of type" error.

import java.util.Random;

public class tesn{
public void hi(void){
System.out.println("DoSTuff");
}
public static void main(String args[]){
hi();
}
}

The filename is called tesn.java. I have no idea why this does not work.


Posted
I must be losing it. Every time I try to compile this simple program it is giving me a "illegal start of type" error.

import java.util.Random;

public class tesn{
public void hi(void){
System.out.println("DoSTuff");
}
public static void main(String args[]){
hi();
}
}

The filename is called tesn.java. I have no idea why this does not work.

Shouldn't it be something like this --

import java.util.Random;

public class test{
public void hi(void){
System.out.println("DoSTuff");
}
public static void main(String args[]){
hi();
}
}

You have "public class tesn{" and I think it should be "public class test{"

Posted (edited)

Nope that isn't it. The class name "tesn" matches the name of the file "tesn.java". It's an odd name, but as long as it matches it should work.

Edit: I figured it out. The void isn't suppost to be where the arguments are. I hate it when I confuse languages.

Edited by I_Broke_My_MHZ

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...