class Demo{
public static void main(String[] args) {
Integer i = Integer.valueOf(127);
Integer j = Integer.valueOf(127);
System.out.println(i==j);
Integer k = Integer.valueOf(128);
Integer l = Integer.valueOf(128);
System.out.println(k==l);
}
}
Run Code Online (Sandbox Code Playgroud)
第一个print语句打印为true,而第二个打印语句打印为false.为什么?请详细解释.
代码给出了nullpointer异常的错误..... wat做什么?
import java.awt.event.*;
import javax.swing.*;
public class Gui implements ActionListener{
JButton button;
public Gui(){
JFrame frame=new JFrame();
JButton button =new JButton("click me!");
button.addActionListener(this);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add(button);
frame.setSize(270,300);
frame.setVisible(true);
}
public static void main(String[] args){
new Gui();
}
public void actionPerformed(ActionEvent e){
button.setText("I've been clicked");
}
}
Run Code Online (Sandbox Code Playgroud)