Home >Java >JavaBase >The difference between long and Long in java

The difference between long and Long in java

王林
王林Original
2019-11-18 13:39:586037browse

The difference between long and Long in java

The difference between long and Long in java is:

1. Long is the basic data type in java, and Long is an object in java Type;

2. For Long type data, the data is an object, while for long type data, the data is a basic data type and does not belong to an object.

Java data types are divided into two types:

1. Basic types: byte(8), short(16), int(32), long(64) ), float(32), double(64), char(16), boolean(1);

2. Object type: Byte, Short, Integer, Long, Float, Double, Character, Boolean.

The above object types are wrapper classes of basic types. For example, Byte is a wrapper class of byte.

The Java language is an object-oriented language, but the basic data types in Java are not object-oriented, which causes a lot of inconveniences in actual use. In order to solve this shortcoming, when designing classes, A corresponding class is designed to represent each basic data type, so the eight classes corresponding to the basic data types are collectively called packaging classes.

As for wrapper classes, these classes mainly have two uses:

Exist as class types corresponding to basic data types to facilitate operations involving objects.

Contains the relevant properties of each basic data type such as maximum value, minimum value, etc., as well as related operation methods.

Comparison of the size of Long data

For Long type data, this data is an object, so the object cannot be directly passed through ">", "== ", "13421faf7c74798f5d6e33fc638e1d1d", "85ab0d779e0002d04a578056049bed13", "==", "<"

long l3 = 300;  
        long l4 = 400;  
  
        System.out.println(l3>l4);  
  
        System.out.println(l3<l4);  
  
        System.out.println(l3==l4);

Recommended tutorial :JavaTutorial

The above is the detailed content of The difference between long and Long in java. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn