April 8, 20178 yr 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!
April 8, 20178 yr 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
April 8, 20178 yr 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?
April 8, 20178 yr 3 minutes ago, Explv said: Perhaps you should learn what public and static mean? what do
April 8, 20178 yr Author 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
April 9, 20178 yr 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.
Create an account or sign in to comment