Home / Programs / long Datatype in Java
🚀 Programming Example

long Datatype in Java

👁 2,252 Views
💻 Practical Program
📘 Step Learning
long Datatype in Java

📌 Information & Algorithm

  • Long data type is a 64-bit signed two's complement integer
  • Minimum value is -9,223,372,036,854,775,808(-2^63)
  • Maximum value is 9,223,372,036,854,775,807 (inclusive)(2^63 -1)
  • This type is used when a wider range than int is needed
  • Default value is 0L
  • Example: long a = 100000L, long b = -200000L

💻 Program Code

 public class LongDataType {

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

 
                        

🖥 Program Output

100000
-200000
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.