Home / Programs / int Datatype in Java
🚀 Programming Example

int Datatype in Java

👁 2,720 Views
💻 Practical Program
📘 Step Learning
int Datatype in Java

📌 Information & Algorithm

  • Int data type is a 32-bit signed two's complement integer.

  • Minimum value is - 2,147,483,648 (-2^31)

  • Maximum value is 2,147,483,647(inclusive) (2^31 -1)

  • Integer is generally used as the default data type for integral values unless there is a concern about memory.

  • The default value is 0

  • Example: int a = 100000, int b = -200000

💻 Program Code

 public class IntDataType {

   public static void main(String []args) {
      // this is declaration and initialization of variable a
	  // datatype is int
	  int a = 10000;
	  // this is declaration and initialization of variable b
	  // datatype is int
      int b = -5000;
      System.out.println(a); // it will print a variable
      System.out.println(b); // it will print b variable
   }
}

  
                        

🖥 Program Output

10000
-5000
Press any key to continue . . .
                            
📚 Learning Subject

Master Programming Through Practical Examples

Improve your coding logic, problem-solving skills and programming confidence by practicing real-world examples with explanations.

🎯 How to learn from this example

First understand the algorithm carefully. Then study the program line-by-line and compare it with the output. Finally, review the explanation section to strengthen your logic and programming understanding.

🔥 Practice suggestion

Rewrite the program without looking at the code. Modify values, conditions or logic and run it again. This helps improve confidence and strengthens coding skills much faster.