Java Write Once, Run Anywhere.
W.O.R.A. = Write Once, Run Anywhere
This is achieved by the JVM (Java Virtual Machine).
Every program must have a Class Java starts execution from main method statements end with semicolons ;
1
2
3
4
5
6
7
8
class MyClass
{
public static void main(String[ ] args) {
System.out.println("Hello world!");
}
}
1
/** This is a documentation comment */
1
2
3
4
5
/**********************
This is the start of a method
***********************/
Java arithmetic operators:
1
2
3
4
5
+ addition
- subtraction
* multiplication
/ division
% modulo
Operators
Any of the following comparison operators may be used to form the condition:
1
2
3
4
5
6
7
8
< less than
> greater than
!= not equal to
== equal to
<= less than or equal to
>= greater than or equal to
VOID
When you do not need to return any value from your method, use the keyword void. Notice the void keyword in the definition of the main method
- this means that main does not return anything.
- Use an ArrayList when you need rapid access to your data.
- Use a LinkedList when you need to make a large number of inserts and/or deletes.
- Arrays and Lists store elements as ordered collections, with each element given an integer index.
- HashMap (like a php associative array) is used for storing data collections as key and value pairs. One object is used as a key (index) to another object (the value).
- The put, remove, and get methods are used to add, delete, and access values in the HashMap.
RESTful API Design
For designing REST API endpoint we recommend 13 Best Practices to Make Your Users Happy.
- Learn the basics of HTTP applied to REST
- Don’t return plain text
- Avoid using verbs in URIs
- Use plural resource nouns
- Return error details in the response body
- Pay attention to status codes
- Use status codes consistently
- Don’t nest resources
- Handle trailing slashes gracefully
- Make use of the querystring for filtering and pagination
- Learn the difference between
401 Unauthorized
and403 Forbidden
- Make good use of
202 Accepted
- Use a web framework specialised in REST APIs
Trivia:
[Dependency Injection Made Simple with Java Examples Clean Code and Best Practices](https://www.youtube.com/watch?v=GATSXm7WAxU)
Start daily exercises in the Code Gym