This follows up on this:
- If you right-click on the topmost folder in Red Hat JBoss Developer Studio and pick "Export..." you may put your code into a .jar file which is double-clickable to be run like an .exe. The Java Decompiler is a tool for seeing what Java is in a .jar file.
- Static methods in cannot reference instance variables.
- The final keyword is like the const keyword in C#.
- The transient keyword means "ignore this when serializing" more or less. This was actually skipped in the training I saw and I had to Google it.
- Instead of the colon for inheritance/implementations in C#, we have the extends keyword for inheriting from a class and the implements keyword for implementing an interface.
- Abstract classes may implement interfaces while not hydrating all of their methods without a compiler error.
- The synchronized keyword is for the multithread stuff in Java. The code here is creating a lock around foo and making the stuff in the synchronized code block happen on a separate thread where, beyond the immediate method that would hold this code, the baz instance variable on the class is set to: "qux"
string foo = "Bar";
synchronized(foo){
this.baz = "qux";
} - If yin is of type Yang here, we will get the affirmation. Note that the type check will not work with a null value even if Yang was used in the variable declaration.
if (yin instanceof Yang)
System.out.println("affirmation");
} - There are different kinds of exceptions in Java just like in C#.
throw NullPointerException("yikes!"); - The += stuff in C# is in Java too and there is also *=, -=, /=, and %= though I cannot imagine ever using these. All of the other operators so far look the same as those of C#.
- The substring in Java is like the Substring in C# and the indexOf in Java is like the indexOf in JavaScript, finding a numeric value for where in a string a match starts.
- There is the concept of private constructors in Java and these make a class impossible to instantiate. Basically you use the static keyword at a method and to make the class wrapping it static too you have a private constructor.
- If you print an object you'll get a hash code. Two objects made from the same class with have two different hash codes.
- do {
counter = counter + 1;
System.out.println("working");
} while (counter < 13);
Do you see the difference between having a judgment at the end of a loop as above or at the beginning like so:
while (counter < 13) {
counter = counter + 1;
System.out.println("working");
}
Addendum 10/2/2019: My mother would have referred to the thing at the top of the last bullet as a "do loop" in her IBM days.
No comments:
Post a Comment