Thoughts
The Java is there from a number of years. A lot of articles, docs, solutions are available. I find it difficult to follow what is it that I should learn about.
To my knowledge (hands-on), Java is used for
- coding as high-level language for building systems,
- compilers (examples, https://github.com/apache/systemds),
- Java API Clients (https://cloud.google.com/java/docs/reference),
- Building websites (https://github.com/JetBrains/kotlin-web-site)
Java as a API client is powerful.
Space Rocket loading project
https://github.com/j143/java-basic-space-challenge
phase-1.txt
building tools=2000
building tools=2000
building tools=2000
building tools=5000
building tools=5000
building tools=2000
building tools=1000
building tools=5000
building tools=6000
shelter equipment=5000
construction equipment=5000
plants=1000
steel=8000
books=1000
water=5000
phase-2.txt
habitat=3000
colony=5000
food=5000
habitat=3000
colony=5000
food=3000
colony=5000
food=3000
static
keyword
Static fields
// Person.java
public class Person {
public static int instanceCount;
public int localCount;
public Person() {
instanceCount++;
localCount++;
}
}
//Main.java
public class Main {
public static void main(String [] args) {
for(int i=0; i < 4; i++) {
Person person = new Person();
System.out.println("(" + person.localCount + ", " + + person.instanceCount + ")");
}
}
}
output will be: (1, 4)
Static Method
Like static fields, static methods belong to class not objects.
Points:
- This is a method independent of the object
- A static method takes in input arguments and returns result based on input only nothing else
- The static method does not need any field values
- But, a static method can still access static fields since they belong the Class
public class Compute {
public static int add(int x, int y) {
return x + y;
}
public static int subtract(int x, int y) {
return x - y;
}
}
add
and subtract
methods can be called without creating the object.
Compute.add(2,3);
Top comments (2)
Wishing you success on your journey to learn Java!
Thanks. :)