obasan Posted April 8, 2017 Posted April 8, 2017 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!
Token Posted April 8, 2017 Posted April 8, 2017 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
Explv Posted April 8, 2017 Posted April 8, 2017 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? 1
Deceiver Posted April 8, 2017 Posted April 8, 2017 3 minutes ago, Explv said: Perhaps you should learn what public and static mean? what do
obasan Posted April 8, 2017 Author Posted April 8, 2017 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
liverare Posted April 9, 2017 Posted April 9, 2017 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.