.code { background:#f5f8fa; background-repeat:no-repeat; border: solid #5C7B90; border-width: 1px 1px 1px 20px; color: #000000; font: 13px 'Courier New', Courier, monospace; line-height: 16px; margin: 10px 0 10px 10px; max-height: 200px; min-height: 16px; overflow: auto; padding: 28px 10px 10px; width: 90%; } .code:hover { background-repeat:no-repeat; }

Sunday, August 30, 2020

Java For Beginners

Java hello world.

  1. public class student{
  2.     public static void main(String[] args){
  3.         System.out.println("Hello World!");
  4.     }
  5. }
  • here public and class is the keyword 
  • student is the name of the class
  • public keyword is called access modifier but it is optional
  • static is the keyword by the help of which we don't have to make the object of the class because its belongs to class.
  • main it is the method which is compulsory in java.
  • method is the group of statements here line no 3 is the statement.
  • line 3 print the Hello World! because it is the print statements.

variable:

  • int num = 2147483647;
  • long num1 = 2147483647; (here java knows that it is in int range
  • long num2 = 2147483648L;(here we have to specify because it is out of range of int so we have to add the L at the last.