API就是jdk提供的各种类,通过帮助文档可以学习这些类


java.lang包不用导包,其他包需要导入包。






package com.heima;
import javax.swing.*;
/*
构造方法
JButton(String text):创建一个带文本的按钮
成员方法
void setSize(int width, int height):设置大小
void setLocation(int x, int y):设置位置(x坐标,y坐标)
*/
public class windows {
public static void main(String[] args) {
//创建窗体对象
JFrame jf = new JFrame();
jf.setTitle("窗口中添加按钮");
jf.setSize(400, 300);
jf.setDefaultCloseOperation(3);
jf.setLocationRelativeTo(null);
jf.setAlwaysOnTop(true);
jf.setLayout(null); //取消窗体的默认布局
//JButton(String text):创建一个带文本的按钮
JButton btn = new JButton("我是按钮");
// //void setSize(int width, int height):设置大小
// btn.setSize(100,20);
// //void setLocation(int x, int y):设置位置(x坐标,y坐标)
btn.setLocation(0,0);
// btn.setLocation(100,100);
btn.setBounds(100,100,100,20);
JButton btn2 = new JButton("我是按钮2");
btn2.setBounds(100,120,100,20);
jf.add(btn);
jf.add(btn2);
//设置窗体可见
jf.setVisible(true);
}
}
显示文字和图像








下面都输出了false


我们平时计算除法是时候,遇到小数时候会有差错,
这时候使用BigDecimal



引用类型才用null
Integer i = null



