Home Java Write Once, Run Anywhere
Post
Cancel

Java Write Once, Run Anywhere

Java Write Once, Run Anywhere.

W.O.R.A. = Write Once, Run Anywhere

This is achieved by the JVM (Java Virtual Machine).

logo

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.
  1. Arrays and Lists store elements as ordered collections, with each element given an integer index.
  2. 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).
  3. 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.

  1. Learn the basics of HTTP applied to REST
  2. Don’t return plain text
  3. Avoid using verbs in URIs
  4. Use plural resource nouns
  5. Return error details in the response body
  6. Pay attention to status codes
  7. Use status codes consistently
  8. Don’t nest resources
  9. Handle trailing slashes gracefully
  10. Make use of the querystring for filtering and pagination
  11. Learn the difference between 401 Unauthorized and 403 Forbidden
  12. Make good use of 202 Accepted
  13. Use a web framework specialised in REST APIs

tools


Trivia:


Start daily exercises in the Code Gym

Start with: Start your journey to become a Java Developer

Continue with: What is Maven

This post is licensed under CC BY 4.0 by the author.