understanding the difference between null and '\u0000' in java

public class MyClass {
    public static void main(String args[]) {
        char c = '\u000'; // [1]
        System.out.println("\u000:" + c);
    }
}

above code jdk is 1.8 or above 1.8. [1]'s error is

MyClass.java:3: error: illegal unicode escape
        char c = '\u000';

it should be '\u0000';

then output is:

:

For type char, the default value is the null character, that is, '\u0000'.

4.1. The Kinds of Types and Values

There are two kinds of types in the Java programming language: primitive types (§4.2) and reference types (§4.3). There are, correspondingly, two kinds of data values that can be stored in variables, passed as arguments, returned by methods, and operated on: primitive values (§4.2) and reference values (§4.3).


Type:
    PrimitiveType
    ReferenceType

There is also a special null type, the type of the expression null (§3.10.7§15.8.1), which has no name.

Because the null type has no name, it is impossible to declare a variable of the null type or to cast to the null type.

The null reference is the only possible value of an expression of null type.

The null reference can always undergo a widening reference conversion to any reference type.

In practice, the programmer can ignore the null type and just pretend that null is merely a special literal that can be of any reference type.

 

3.10.7. The Null Literal

The null type has one value, the null reference, represented by the null literal null, which is formed from ASCII characters.


NullLiteral:
    null

A null literal is always of the null type (§4.1).

15.8.1. Lexical Literals

A literal (§3.10) denotes a fixed, unchanging value.

The following production from §3.10 is repeated here for convenience:


Literal:
    IntegerLiteral
    FloatingPointLiteral
    BooleanLiteral
    CharacterLiteral
    StringLiteral
    NullLiteral

The type of a literal is determined as follows:

  • The type of an integer literal (§3.10.1) that ends with L or l is long (§4.2.1).

    The type of any other integer literal is int (§4.2.1).

  • The type of a floating-point literal (§3.10.2) that ends with F or f is float and its value must be an element of the float value set (§4.2.3).

    The type of any other floating-point literal is double and its value must be an element of the double value set (§4.2.3).

  • The type of a boolean literal (§3.10.3) is boolean (§4.2.5).

  • The type of a character literal (§3.10.4) is char (§4.2.1).

  • The type of a string literal (§3.10.5) is String (§4.3.3).

  • The type of the null literal null (§3.10.7) is the null type (§4.1); its value is the null reference.

Evaluation of a lexical literal always completes normally.

 

4.2.1. Integral Types and Values

The values of the integral types are integers in the following ranges:

  • For byte, from -128 to 127, inclusive

  • For short, from -32768 to 32767, inclusive

  • For int, from -2147483648 to 2147483647, inclusive

  • For long, from -9223372036854775808 to 9223372036854775807, inclusive

  • For char, from '\u0000' to '\uffff' inclusive, that is, from 0 to 65535

 

references:

1. https://stackoverflow.com/questions/12195628/understanding-the-difference-between-null-and-u000-in-java

2. https://docs.oracle.com/javase/specs/jvms/se6/html/Concepts.doc.html#22930

3. https://docs.oracle.com/javase/specs/jls/se7/html/jls-4.html

4. https://docs.oracle.com/javase/specs/jls/se7/html/jls-3.html#jls-3.10.7

5. https://docs.oracle.com/javase/specs/jls/se7/html/jls-15.html#jls-15.8.1

基于Python的天气预测与可视化(完整源码+说明文档+数据),个人经导师指导并认可通过的高分设计项目,评审分99分,代码完整确保可以运行,小白也可以亲自搞定,主要针对计算机相关专业的正在做大作业的学生和需要项目实战练习的学习者,可作为毕业设计、课程设计、期末大作业,代码资料完整,下载可用。 基于Python的天气预测与可视化(完整源码+说明文档+数据)基于Python的天气预测与可视化(完整源码+说明文档+数据)基于Python的天气预测与可视化(完整源码+说明文档+数据)基于Python的天气预测与可视化(完整源码+说明文档+数据)基于Python的天气预测与可视化(完整源码+说明文档+数据)基于Python的天气预测与可视化(完整源码+说明文档+数据)基于Python的天气预测与可视化(完整源码+说明文档+数据)基于Python的天气预测与可视化(完整源码+说明文档+数据)基于Python的天气预测与可视化(完整源码+说明文档+数据)基于Python的天气预测与可视化(完整源码+说明文档+数据)基于Python的天气预测与可视化(完整源码+说明文档+数据)基于Python的天气预测与可视化(完整源码+说明文档+数据)基于Python的天气预测与可视化(完整源码+说明文档+数据)基于Python的天气预测与可视化(完整源码+说明文档+数据)基于Python的天气预测与可视化(完整源码+说明文档+数据)基于Python的天气预测与可视化(完整源码+说明文档+数据)基于Python的天气预测与可视化(完整源码+说明文档+数据)基于Python的天气预测与可视化(完整源码+说明文档+数据)基于Python的天气预测与可视化(完整源码+说明文档+数据)基于Python的天气预测与可视化(完整源码+说明文档+数据)基于Python的天气预测与可视化(完整源码+说明文档+数据)基
### Understanding the Difference Between `mtcars[1]` and `mtcars[[1]]` In R programming, understanding how to access elements within a data frame like `mtcars` involves recognizing different types of indexing methods. When using `mtcars[1]`, this refers to selecting the first column of the data frame as another **data frame** containing only that single column. This method retains the structure of the original object, meaning it still behaves as a subsetted version of the parent data frame[^1]. For example: ```r subset_df <- mtcars[1] class(subset_df) # Returns "data.frame" ``` On the other hand, when employing `mtcars[[1]]`, what gets returned is specifically the vector corresponding to the values contained in the first column of the data frame. Here, instead of maintaining the entire structural context of being part of a larger entity such as a dataframe, just an atomic vector representing those entries alone comes out without any additional metadata about its origin from said table-like construct[^2]: ```r vector_column <- mtcars[[1]] class(vector_column) # Returns "numeric" or similar depending on content type. ``` This distinction matters because operations performed upon these two results may vary significantly based not merely their contents but also due differences inherent between them regarding class definitions which affect applicable functions available thereafter accordingly during further computations involving either result obtained through respective means described above concerning accessing parts inside structured datasets represented by frames under consideration here today discussing distinctions made clear now hopefully better understood thanks provided explanations alongside illustrative code snippets demonstrating practical implications thereof too!
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值