Sigma Posted March 24, 2014 Share Posted March 24, 2014 (edited) thisIsCamelCase You use the above syntax to denote a field that is not final, examples: int numOne; Object objOne; public protected private abstract static final synchonized The above are modifiers you use before defining a field or method, examples: public static final String NAME; protected void method1() { } That is the order you should be putting them in, omitting any unused modifiers. You'll probably never use transient, volatile, or native modifiers, so they won't be included in the above order. byte short int long float double boolean char The above are primitive data types that you are able to compare equality with the == operator, examples: int numOne = 1; int numTwo = 2; public static void main(String[] args) { System.out.println(numOne == numTwo); //If you run the above code, it will print out as 'false' } ClazzName The above is the correct syntax for class names; the first letter of each word should be capitalized, examples: class TestClazz { } class TipsOnHowToNotBeBad { } I_AM_A_FINAL_FIELD The above is the correct syntax for defining a final field, examples: int MAX_VALUE = Integer.MAX_VALUE; int MIN_VALUE = Integer.MIN_VALUE; .equals(Object obj) The above is a method that is inherited from the Object class. It is used to compare two objects for equality (do not use the == operator, as stated in a previous lesson above it is for primitive data types only), examples: String cheese = "Cheese"; String cheese2 = "Cheese"; public static void main(String[] args) { System.out.println(cheese.equals(cheese2)); //If you run the above code, it will print out as 'true' } public void method1() { } public void method2() { } public void method3(){ } The above are three different ways to format your braces in java. All 3 are correct, but you should never mix one with another. if (booleanValue) method1(); The above is an if statement that has the braces omitted. You should only do this if there is only one line of code that is executed inside the if statement (note that you can also do this with for and while loops). int numOne; String stringOne; public Clazz(int numOne) { this(numOne, "Default); } public Clazz(int numOne, String stringOne) { this.numOne = numOne; this.stringOne = stringOne; } The above is an example of Constructor overloading. In the first constructor, you are only required to pass in an int, and the String field is automatically assigned whereas in the second constructor you are required to provide both an int and a String. If you learned anything from this, congratulations, you're less bad than you were before. Edited March 24, 2014 by Sigma Link to comment Share on other sites More sharing options...
GoldenGates Posted March 24, 2014 Share Posted March 24, 2014 I wouldn't even be surprised if an SDN Scripter learnt a thing or two from this. :unsure: 1 Link to comment Share on other sites More sharing options...
Jack Posted March 24, 2014 Share Posted March 24, 2014 Anyone who has had a real programming class should know this. This is great for beginners though. Link to comment Share on other sites More sharing options...
Dog_ Posted March 24, 2014 Share Posted March 24, 2014 Should mention this if (boolean == true) And if (boolean == false) I've seen a lot of script writers do that lately.. 2 Link to comment Share on other sites More sharing options...
GoldenGates Posted March 24, 2014 Share Posted March 24, 2014 Should mention this if (boolean == true) And if (boolean == false) I've seen a lot of script writers do that lately.. I remember doing this sooo long ago, I felt so stupid when I realised what I was doing wrong lmao. (Not that it's wrong) Link to comment Share on other sites More sharing options...
Dog_ Posted March 24, 2014 Share Posted March 24, 2014 I remember doing this sooo long ago, I felt so stupid when I realised what I was doing wrong lmao. (Not that it's wrong)didnt you just do it yesterday? Link to comment Share on other sites More sharing options...
GoldenGates Posted March 24, 2014 Share Posted March 24, 2014 didnt you just do it yesterday? Yes. No. Link to comment Share on other sites More sharing options...
Sigma Posted March 24, 2014 Author Share Posted March 24, 2014 Should mention this if (boolean == true) And if (boolean == false) I've seen a lot of script writers do that lately.. That isn't wrong, it's just more code. Link to comment Share on other sites More sharing options...
Dog_ Posted March 24, 2014 Share Posted March 24, 2014 That isn't wrong, it's just more code.i know but it's worth mentioning because it looks completely retarded Link to comment Share on other sites More sharing options...
diamondcut11 Posted March 24, 2014 Share Posted March 24, 2014 Learned a few things from this, thanks! Link to comment Share on other sites More sharing options...
Joseph Posted March 24, 2014 Share Posted March 24, 2014 Where you have method 1, 2, 3 don't forget to add the () Link to comment Share on other sites More sharing options...
Booch Posted March 24, 2014 Share Posted March 24, 2014 Mention constructors and constructor overloading. Beginners get stuck when learning object oriented programming and maybe some getter/setter methods too. Great basic tutorial which scripters SHOULD all know. ^_^ Link to comment Share on other sites More sharing options...
PolishCivil Posted March 24, 2014 Share Posted March 24, 2014 lol, are you serious. Link to comment Share on other sites More sharing options...
Haxball Posted March 24, 2014 Share Posted March 24, 2014 Since I'm still learning any tip is great. Thanks! Link to comment Share on other sites More sharing options...
Sigma Posted March 24, 2014 Author Share Posted March 24, 2014 Where you have method 1, 2, 3 don't forget to add the () Good catch, it was pretty late when I was writing this. lol, are you serious. Of course. If you want me to make a tutorial of "your level", please let me know and I'd be happy to have you learn something new. Link to comment Share on other sites More sharing options...