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

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

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

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

    A literal is a constant value which is compatible to a datatype, a literal is used to assign a value to variable, to compare values or define constants. See JLS 3.10.

    e.g:

    int varOfDataTypeInt = 123;
    
    String s = "string literal";
    

提交回复
热议问题