Java t2

Shubham GordeShubham Gorde
1 min read

So in java,

public class Main {
    public static void main(String[] args) {
        // entrypoint
    }
}

this main method is an your entrypoint so basically you can declare variables inside

Let’s start learning datatypes of java

There are two types of datatypes in java one is primitive and non-primitive.

In primitive there are 8 datatypes which are :

  • char

  • byte

  • short

  • int

  • float

  • long

  • double

  • bool

Ok now i am going to give examples about which java variables declaration is invalid and valid.

int arr; // valid

int 1arr; // invalid (can’t start with number)

int arr code; // invalid (can’t use space between the words

Ok so now i would like to tell you it’s ranges means how much data each datatype can store but then blog will be too lengthy. That’s why i am going to put a documentation link here so you can read it there.

https://www.w3schools.com/java/java_data_types.asp

Exersize Question and its answer

q. Add three number and display it in output.

public class Main {
    public static void main(String[] args) {
        int a = 9, b = 5, c = 3, sum;
        sum = a + b + c;
        System.out.println(sum);
    }
}

I hope you liked second java tut.

0
Subscribe to my newsletter

Read articles from Shubham Gorde directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Shubham Gorde
Shubham Gorde