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

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

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

10条回答
  •  不要未来只要你来
    2021-01-30 09:47

    A literal is a fixed value that is assigned to a variable (of a specific data type) directly without using a constructor

    For eg:

    String var1 = "Java"; -- here "Java" is a literal

    String var2 = new String("Java"); -- here "Java" is not a literal

提交回复
热议问题