在java中我们为这样的任何对象赋值null:
private Apple apple = null;
Run Code Online (Sandbox Code Playgroud)
java中有没有与此相关的类null?
因为在Apache common-lang jar中他们定义了这样的null:
public static class Null implements Serializable {
/**
* Required for serialization support. Declare serialization compatibility with Commons Lang 1.0 * * @see java.io.Serializable
*/
private static final long serialVersionUID = 7092611880189329093L;
/**
* Restricted constructor - singleton.
*/
Null() {
super();
}
/**
* <p>Ensure singleton.</p>
*
* @return the singleton value
*/
private Object readResolve() {
return ObjectUtils.NULL;
}
}
Run Code Online (Sandbox Code Playgroud)
为什么他们这样做了?
或者它只是一点点模式?
很长一段时间以来,我第一次一直在虚拟机上使用Delphi,目前正在导入JSON。但是,突然之间(毫无疑问,我已经删除或损坏了某些东西)我无法编译该项目。
每次尝试时,我都会收到消息E003未声明的标识符:“ Form1”,然后编辑器将捕捉到程序文件Project1,即Application.CreateForm(TForm1, Form1);行。
我附加了my unit1.pas,它是表单所在的地方,以及看似相关的其他文件。请帮忙!我做了什么/删除了什么?
unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Xml.xmldom, Xml.XMLIntf,
Xml.XMLDoc, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient, IdHTTP, IdSSLOpenSSL,
IdIOHandler, IdIOHandlerSocket, IdIOHandlerStack, IdSSL, inifiles,
Vcl.ExtCtrls, Vcl.ComCtrls;
const
GstrAPIKey = 'removed this :)';
type
TForm1 = class(TForm)
Button1: TButton;
XMLDocument1: TXMLDocument;
Memo1: TMemo;
IdHTTP1: TIdHTTP;
IdSSL: TIdSSLIOHandlerSocketOpenSSL;
rgrp_Home: TRadioGroup;
cbx_Report: TComboBox;
cbx_Charts: TComboBox;
sb_Main: TStatusBar;
dt_From: TDateTimePicker;
dt_To: TDateTimePicker;
Edit1: TEdit;
lbl_DF: TLabel;
Label1: …Run Code Online (Sandbox Code Playgroud) 文档Integer.toBinaryString说明,它将整数参数的字符串表示形式返回为无符号整数。它还继续指出,负数以正数形式转换为它们的大小。
据我所知,这是负数的二进制补码。但是,当我为负数运行以下命令时,我仍然以有符号形式获得数字的字符串表示形式,即二进制补码。
我在这里错过了什么吗?
System.out.println(Integer.toBinaryString(13)); // 1101
System.out.println(Integer.toBinaryString(-13)); // 11111111111111111111111111110011
Run Code Online (Sandbox Code Playgroud) 我有两个班级 A 级和 B 级。如下:
A类:
class A {
public String a;
public A() {
}
public A(final String a) {
this.a = a;
}
}
Run Code Online (Sandbox Code Playgroud)
B类:
class B {
private A a;
private String b;
public B() {
}
public B(final A a) {
this.a = a;
}
}
Run Code Online (Sandbox Code Playgroud)
我将 A[] 转换为 B[] 的地方如下:
public static void main(final String[] args) {
final A[] myA = new A[3];
myA[0] = new A("a");
myA[1] = new A("b");
myA[2] = new A("c"); …Run Code Online (Sandbox Code Playgroud) 如何使用contains方法仅按 id 进行搜索,我想在不使用循环的情况下检查 id 是否等于 4,如何?
测试班
public class Test {
private int id;
private String name;
private int age;
public Test(int id, String name, int age) {
this.id = id;
this.name = name;
this.age = age;
}
}
Run Code Online (Sandbox Code Playgroud)
设置数据
List <Test> list = new ArrayList <> ();
list.add(new Test(1, "Name 1", 25));
list.add(new Test(2, "Name 2", 37));
list.add(new Test(3, "Name 3", 63));
list.add(new Test(4, "Name 4", 19));
list.add(new Test(5, "Name 5", 56));
Run Code Online (Sandbox Code Playgroud) 在java的String类中,有一个变量定义如下:
private final int offset;
Run Code Online (Sandbox Code Playgroud)
这种抵消有什么作用?