Jump to content

Naming classes


obasan

Recommended Posts

9 minutes ago, obasan said:

What takes more memory?

void horn() {

System.out.println("BEEP");

}

OOORRRR

public static void() {

System.out.println("BEEP");}

 

------

 

Should you avoid using something like public static void when you can just get away with void???

Thanks!

Second one won't even compile, but source code != memory usage

Link to comment
Share on other sites

40 minutes ago, obasan said:

What takes more memory?

void horn() {

System.out.println("BEEP");

}

OOORRRR

public static void() {

System.out.println("BEEP");}

 

------

 

Should you avoid using something like public static void when you can just get away with void???

Thanks!

Perhaps you should learn what public and static mean?

  • Like 1
Link to comment
Share on other sites

11 hours ago, Explv said:

Perhaps you should learn what public and static mean?

public means that the class or object can be seen by others

static has something to do with instantiating or something.

12 hours ago, Token said:

Second one won't even compile, but source code != memory usage

fuk lol i forgot the add the horn() so its:

 

public static void horn() {

System.out.println("BEEP");

}

 

either way, what does use memory?

im guessing its all about calculations and variables you create...

i.e. dont use a double when u can get away with an int

i.e. find the most effective calculation method

Link to comment
Share on other sites

Static is used when you want something to exist once.

For example:

Cat.purr(); // static - makes no sense. Cats purr individually.

Cat.count(); // static - makes sense. Get the count of all cats ever created.

new Cat().purr(); // not static - makes sense. Cats purr individually.

new Cat().count(); // not static - makes no sense. One cat can't account for all cats ever created.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

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