11 Replies - 728 Views - Last Post: 22 October 2016 - 03:42 AM Rate Topic: -----

#1 lester23   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 21-October 16

Exception in thread "main" java.lang.Error: Unresolved compila

Posted 21 October 2016 - 05:03 PM

Here is my code please help!!!!!!!!!!11


Attached Image
Attached Image
Is This A Good Question/Topic? 0
  • +

Replies To: Exception in thread "main" java.lang.Error: Unresolved compila

#2 NormR   User is offline

  • D.I.C Lover
  • member icon

Reputation: 691
  • View blog
  • Posts: 5,267
  • Joined: 25-December 13

Re: Exception in thread "main" java.lang.Error: Unresolved compila

Posted 21 October 2016 - 05:08 PM

Please copy the full text of the compiler's error message and paste it here.

Also paste the source code wrapped in code tags.

No images.
Was This Post Helpful? 1
  • +
  • -

#3 lester23   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 21-October 16

Re: Exception in thread "main" java.lang.Error: Unresolved compila

Posted 21 October 2016 - 05:11 PM

------------------------------------------------------Error---------------------------------------------------------------------

Exception in thread "main" java.lang.Error: Unresolved compilation problems:
void is an invalid type for the variable House
Syntax error on token "(", ; expected
Syntax error on token ",", ; expected
Syntax error on token ",", ; expected
Syntax error on token ")", ; expected

at Practice.House.main(House.java:7)


----------------------------------------------------House.java------------------------------------------------------------------


package Practice;

public class House{

public static void main(String[]args){

private void House(int w, int e,; int r){
w = 80;
e = 120;
r = 1200;
}
}
}

--------------------------------------------------------DeluxeHouse.java-----------------------------------------------------------


package Practice;

public class DeluxeHouse extends House {

private int water2;
private int elect2;
private int rent2;

public DeluxeHouse(){

water2 = 80 * 2;
elect2 = 120 * 2;
rent2 = 1200 * 2;
}

private void cost(){
System.out.println(water2);
System.out.println(elect2);
System.out.println(rent2);
}
}

-----------------------------------------------------------------------------------------------------------------------------------

Here u got man, tell me if u need something else :)
Was This Post Helpful? 0
  • +
  • -

#4 NormR   User is offline

  • D.I.C Lover
  • member icon

Reputation: 691
  • View blog
  • Posts: 5,267
  • Joined: 25-December 13

Re: Exception in thread "main" java.lang.Error: Unresolved compila

Posted 21 October 2016 - 05:16 PM

You need to wrap the code in code tags so the statements are numbered and the code's formatting is preserved.

Posted Image


It looks like the ending } is missing for the main() method. The House() method is wrongly coded to be inside of the main() method. A method can not be defined inside of another method.

If you mean for the House method to be the constructor, remove the void. Constructors don't return anything.

This post has been edited by NormR: 21 October 2016 - 05:17 PM

Was This Post Helpful? 0
  • +
  • -

#5 lester23   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 21-October 16

Re: Exception in thread "main" java.lang.Error: Unresolved compila

Posted 21 October 2016 - 05:59 PM

View PostNormR, on 21 October 2016 - 05:16 PM, said:

You need to wrap the code in code tags so the statements are numbered and the code's formatting is preserved.

Posted Image


It looks like the ending } is missing for the main() method. The House() method is wrongly coded to be inside of the main() method. A method can not be defined inside of another method.

If you mean for the House method to be the constructor, remove the void. Constructors don't return anything.




is this right

package Practice;

public class House {

private House(int water, int rent){



}


}
Was This Post Helpful? 0
  • +
  • -

#6 NormR   User is offline

  • D.I.C Lover
  • member icon

Reputation: 691
  • View blog
  • Posts: 5,267
  • Joined: 25-December 13

Re: Exception in thread "main" java.lang.Error: Unresolved compila

Posted 21 October 2016 - 06:06 PM

Please wrap all posted code in code tags.

Quote

is this right

What happened when you tried to compile it?
Was This Post Helpful? 0
  • +
  • -

#7 lester23   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 21-October 16

Re: Exception in thread "main" java.lang.Error: Unresolved compila

Posted 21 October 2016 - 06:15 PM

View PostNormR, on 21 October 2016 - 06:06 PM, said:

Please wrap all posted code in code tags.

Quote

is this right

What happened when you tried to compile it?


nothing when i click run nothing happen on the console

View PostNormR, on 21 October 2016 - 06:06 PM, said:

Please wrap all posted code in code tags.

Quote

is this right

What happened when you tried to compile it?


here the code i change it
package Practice;

public class House {

private House(int water, int rent){



}


}
Was This Post Helpful? 0
  • +
  • -

#8 NormR   User is offline

  • D.I.C Lover
  • member icon

Reputation: 691
  • View blog
  • Posts: 5,267
  • Joined: 25-December 13

Re: Exception in thread "main" java.lang.Error: Unresolved compila

Posted 21 October 2016 - 06:18 PM

Are there any compiler errors?

Quote

nothing happen on the console

If you want to see anything on the console when the program executes you need to
1) add a main() method
2) add some print statements that print messages to the console.

Please wrap all posted code in code tags.

Was This Post Helpful? 0
  • +
  • -

#9 lester23   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 21-October 16

Re: Exception in thread "main" java.lang.Error: Unresolved compila

Posted 21 October 2016 - 06:31 PM

View PostNormR, on 21 October 2016 - 06:18 PM, said:

Are there any compiler errors?

Quote

nothing happen on the console

If you want to see anything on the console when the program executes you need to
1) add a main() method
2) add some print statements that print messages to the console.

Please wrap all posted code in code tags.



yeah there was an error my bad i didnt see it but this is what it give me

package Practice;

public class House {
	
	private House(int water, int rent){
		
		
		
	}
	
Error: Main method not found in class Practice.House, please define the main method as:
   public static void main(String[] args)
or a JavaFX application class must extend javafx.application.Application


Was This Post Helpful? 0
  • +
  • -

#10 NormR   User is offline

  • D.I.C Lover
  • member icon

Reputation: 691
  • View blog
  • Posts: 5,267
  • Joined: 25-December 13

Re: Exception in thread "main" java.lang.Error: Unresolved compila

Posted 21 October 2016 - 06:35 PM

Look at the error message, especially on lines 11 and 12. That tells you what is needed in the code so that the code can be executed.

Take a look at the tutorial on how to code a HelloWorld program. It has a main() method. http://docs.oracle.c...java/win32.html

I'm done for tonight.

This post has been edited by NormR: 21 October 2016 - 06:35 PM

Was This Post Helpful? 0
  • +
  • -

#11 lester23   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 21-October 16

Re: Exception in thread "main" java.lang.Error: Unresolved compila

Posted 21 October 2016 - 06:54 PM

View PostNormR, on 21 October 2016 - 06:35 PM, said:

Look at the error message, especially on lines 11 and 12. That tells you what is needed in the code so that the code can be executed.

Take a look at the tutorial on how to code a HelloWorld program. It has a main() method. http://docs.oracle.c...java/win32.html

I'm done for tonight.

ok goodnight thanks but one more thing do i put the private house in send of public static void main(String[] args)

View Postlester23, on 21 October 2016 - 06:53 PM, said:

View PostNormR, on 21 October 2016 - 06:35 PM, said:

Look at the error message, especially on lines 11 and 12. That tells you what is needed in the code so that the code can be executed.

Take a look at the tutorial on how to code a HelloWorld program. It has a main() method. http://docs.oracle.c...java/win32.html

I'm done for tonight.

ok goodnight thanks but one more thing do i put the private house inside of public static void main(String[] args)

Was This Post Helpful? 0
  • +
  • -

#12 NormR   User is offline

  • D.I.C Lover
  • member icon

Reputation: 691
  • View blog
  • Posts: 5,267
  • Joined: 25-December 13

Re: Exception in thread "main" java.lang.Error: Unresolved compila

Posted 22 October 2016 - 03:42 AM

Quote

do i put the private house in send of public static void main(String[] args)

No. Do not define one method inside of another method.
Also constructors are normally public, not private.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1