What is the difference between data types and literals in Java?

前端 未结 10 1714
旧时难觅i
旧时难觅i 2021-01-30 08:59

What is the difference between data types and literals in Java?

10条回答
  •  佛祖请我去吃肉
    2021-01-30 09:48

    Data types are just, well, different types of data, like Strings or floats or ArrayLists. In Java, most data types are classes. Edit although according to one of the other answers, I think maybe the term "data type" might be used more for primitives, i.e. types that are not classes.

    A literal is a way of expressing a value without having to create it using a constructor. For example, if you just put 3 in your code, it means the int 3. You don't have to say new Integer(3) or anything like that.

    By the way, may I recommend the official Java Tutorials.

提交回复
热议问题