1195 - Basically Speaking

Discussion around the problems of the COJ.
Forum rules
Remember that posting AC code is not allowed here. If you are going to ask a question or to post a solution, describe your algorithm instead. Posting AC code will be penalized.
Post Reply
User avatar
dovier
Posts: 1143
Joined: 9 years ago
Location: Havana, Cuba
Gender: Male
Cuba

1195 - Basically Speaking

Post by dovier » 9 years ago




misaelmt
Posts: 3
Joined: 8 years ago
Gender: None specified

Re: 1195 - Basically Speaking

Post by misaelmt » 6 years ago

I send:

Code: Select all

class Main {
	public static void main(String[] args) {
		System.out.println("ss");
	}
}
And I got Runtime Error

Whats wrong???
Im asking because I send my solution and I always get RE :?

humbertodiaz
Posts: 97
Joined: 6 years ago
Gender: None specified

Re: 1195 - Basically Speaking

Post by humbertodiaz » 6 years ago

Interesting... Your code is virtually the same as the sample Java program provided on the FAQ. I tried it out and confirmed that it gives an RTE. Then I made the class public and it worked. So it seems the sample program is wrong. o_o The error is probably that Java can't find the main() method when the program is executed. Sometimes people have this problem when starting out with online judges and it's terribly confusing.

To be clear, I simply added "public" before "class Main" and got it to work. Also, you don't have to name the class Main. I've been submitting classes with other names and it works fine. Avoid using packages since those would probably cause an RTE.

I'll poke one of the admins to get the example fixed, too...

misaelmt
Posts: 3
Joined: 8 years ago
Gender: None specified

Re: 1195 - Basically Speaking

Post by misaelmt » 6 years ago

Thank you humbertodiaz!
You are right, you have to make the class public and as you said you can name the class whatever you want.
Have a nice week!

Post Reply

Return to “Problem set”