Jump to content

wtf java?

Go to solution Solved by Slottr,

Those statements arent within a codeblock

 

If you're not within a method they won't be registered

 

As I mentioned in your other post, consider looking into using a constructor for your java classes

 

This can also be solved by:

 

{

  //your code outside of a method
  
}

 

This is generally a bad practice though.

Those statements arent within a codeblock

 

If you're not within a method they won't be registered

 

As I mentioned in your other post, consider looking into using a constructor for your java classes

 

This can also be solved by:

 

{

  //your code outside of a method
  
}

 

This is generally a bad practice though.

Community Standards || Tech News Posting Guidelines

---======================================================================---

CPU: R5 9600X || GPU: RX 9070 XT|| Memory: 32GB || Cooler: Peerless Assassin || PSU: RM850e|| Case: Lian Li A3

Link to comment
https://linustechtips.com/topic/1393022-wtf-java/#findComment-15135054
Share on other sites

Link to post
Share on other sites

8 minutes ago, Slottr said:

Those statements arent within a codeblock

 

If you're not within a method they won't be registered

 

As I mentioned in your other post, consider looking into using a constructor for your java classes

 

This can also be solved by:

 

{

  //your code outside of a method
  
}

 

This is generally a bad practice though.

oh so I put them in a code block. I don't care it's a bad practice. I mean OOP is a bad practice for what I am doing because it makes it more confusing but the teacher requires it  and it's a school project.so yeah I am doing it. But note taken not to use those codeblocks in general. Thanks a lot! You saved me a lot of hassle!

Link to comment
https://linustechtips.com/topic/1393022-wtf-java/#findComment-15135060
Share on other sites

Link to post
Share on other sites

4 minutes ago, stefanmz said:

oh so I put them in a code block. I don't care it's a bad practice. I mean OOP is a bad practice for what I am doing because it makes it more confusing but the teacher requires it  and it's a school project.so yeah I am doing it. But note taken not to use those codeblocks in general. Thanks a lot! You saved me a lot of hassle!

Any code you require to run without OOP specifically should be written within a main method then, assuming this is the code you want to execute

Community Standards || Tech News Posting Guidelines

---======================================================================---

CPU: R5 9600X || GPU: RX 9070 XT|| Memory: 32GB || Cooler: Peerless Assassin || PSU: RM850e|| Case: Lian Li A3

Link to comment
https://linustechtips.com/topic/1393022-wtf-java/#findComment-15135064
Share on other sites

Link to post
Share on other sites

50 minutes ago, Slottr said:

Any code you require to run without OOP specifically should be written within a main method then, assuming this is the code you want to execute

no,that's processing it's not just java so there is no main but otherwise I know I have done c#

Link to comment
https://linustechtips.com/topic/1393022-wtf-java/#findComment-15135116
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×