java补全代码 代码补全是什么
Java补全代码
public class Manager extends Employee {
成都网站设计、网站建设介绍好的网站是理念、设计和技术的结合。成都创新互联拥有的网站设计理念、多方位的设计风格、经验丰富的设计团队。提供PC端+手机端网站建设,用营销思维进行网站设计、采用先进技术开源代码、注重用户体验与SEO基础,将技术与创意整合到网站之中,以契合客户的方式做到创意性的视觉化效果。
private String department;
public String getDepartment() {
return department;
}
public void setDepartment(String department) {
this.department = department;
}
public Manager(String name){
super(name);
}
public Manager(String name,String department){
super(name);
this.department = department;
}
}
public class Main {
public static void main(String[] args) {
Scanner sca = new Scanner(System.in);
String str = sca.next();
String str1 = sca.next();
Manager m = new Manager(str, str1);
System.out.println("name:"+m.getName()+" department:"+m.getDepartment());
}
}
如果Main类中不想用getName()和getDepartment()的话,需要在Manager中把name和department定义成public
java 补全代码
楼主,依题意,完整的程序如下:
import java.awt.FlowLayout;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
public class Exam2 extends Thread implements ActionListener
{
//声明界面元素
private JFrame timeFrame;
private JButton startButton;
private JButton stopButton;
private JButton resetButton;
private JLabel timeLabel;
//定义变量存储时、分、秒
int hour = 0;
int minute = 0;
int second = 0;
//声明线程对象
Thread myThread;
public Exam2()
{
timeFrame = new JFrame("计时器");
startButton = new JButton("开始");
stopButton = new JButton("停止");
resetButton = new JButton("重置");
timeLabel = new JLabel("00:00:00");
timeFrame.setLayout(new FlowLayout());
timeFrame.setBounds((Toolkit.getDefaultToolkit().getScreenSize().width - 300)/2,
(Toolkit.getDefaultToolkit().getScreenSize().height - 200)/2, 300, 200);
timeFrame.add(timeLabel);
timeFrame.add(startButton);
timeFrame.add(stopButton);
timeFrame.add(resetButton);
timeFrame.setVisible(true);
timeFrame.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
});
startButton.addActionListener(this);
stopButton.addActionListener(this);
resetButton.addActionListener(this);
myThread = this;
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource() == this.startButton)
{
System.out.println("计时开始...");
if(this.start)
{
this.myThread.start();
}
else
{
this.start = true;
}
}
if(e.getSource() == this.stopButton)
{
System.out.println("计时停止...");
this.start = false;
}
if(e.getSource() == this.resetButton)
{
hour = 0;
minute = 0;
second = 0;
}
}
volatile boolean start = true;
@Override
public void run()
{
while(true)
{
if(this.start)
{
second++;
try
{
Thread.sleep(1000);
} catch (InterruptedException e)
{
e.printStackTrace();
}
if(second = 60)
{
second = 0;
minute++;
}
if(minute = 60)
{
minute = 0;
hour++;
}
showTime();
}
}
}
private void showTime()
{
String strTime = "";
if(hour 10)
{
strTime += "0"+hour + ":";
}
else
{
strTime += hour + ":";
}
if(minute 10)
{
strTime += "0"+minute + ":";
}
else
{
strTime += minute + ":";
}
if(second 10)
{
strTime += "0"+second;
}
else
{
strTime += second;
}
this.timeLabel.setText(strTime);
}
public static void main(String[] args)
{
new Exam2();
}
}
有问题欢迎提问,满意请采纳,谢谢!
java 帮我补全
以下代码仅供参考,用的是另外一种思路
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
public class Main {
public static void main(String[] args) {
Calendar c = Calendar.getInstance();
SimpleDateFormat s = new SimpleDateFormat("yyyy");
int year = Integer.parseInt(s.format(new Date()));
s = new SimpleDateFormat("MM");
int month = Integer.parseInt(s.format(new Date()));
s = new SimpleDateFormat("dd");
int day = c.get(Calendar.DAY_OF_MONTH);
c.set(Calendar.YEAR, year);
c.set(Calendar.MONTH, month);
System.out.println(year + "年" + month + "月" + day + "日" + "\t" + "日历如下:");
c = Calendar.getInstance();
int currentMonth = -1;
c.set(year, 0, 1);
while (c.get(Calendar.YEAR) == year) {
/**
* 判断是否处于同一个月份
* 若不是 则需要输出表头
*
*/
if (currentMonth != c.get(Calendar.MONTH)) {
System.out.println("");
System.out.println("");
currentMonth = c.get(Calendar.MONTH);
System.out.println((currentMonth + 1) + "月");
System.out.println("星期日\t星期一\t星期二\t星期三\t星期四\t星期五\t星期六");
for (int i = 1, k = c.get(Calendar.DAY_OF_WEEK); i k; i++) {
System.out.print(String.format("%1$5s\t", ""));
}
}
System.out.print(String.format("%1$5d\t", c.get(Calendar.DAY_OF_MONTH)));
/**
* 日期+1
*/
c.add(Calendar.DAY_OF_YEAR, 1);
/**
* 当日期是星期天并且不是一个月的最后一天时 输出换行
*/
if (c.get(Calendar.DAY_OF_WEEK) == 1 currentMonth == c.get(Calendar.MONTH)) {
System.out.println("");
}
}
}
}
Java非运行时异常的处理 求大神补全代码
public class FileReaderDemo {
public static void main(String[] args) {
try {
//创建要读取的数据文件的文件对象 file
File file = new File("d:\\data.txt");
//创建要读取数据的输入流
FileReader fileReader = new FileReader(file);
//从输入流中读取一个字符;
int c = fileReader.read();
//判断是否读取到文件结束,如果读取到文件的最后会返回-1
while (c!=-1) {
//输出读取的这个字符
System.out.println((char)c);
//再读取下一个字符
c = fileReader.read();
}
//所有读取完毕后,关闭fileReader对象,要求不管前面是否抛出异常,
//都必须要执行关闭操作。
fileReader.close();
} catch(Exception e) {
e.printStackTrace();
}
}
}
怎样设置Eclipse的java自动补全
步骤
第一步:打开eclipse,随便开一个java文件。
第二步:在代码中右键,选择Preferences。
第三步:再Preferences里选择java
第四步:再选择Editor,再选择Content Assist
第五步:再在所圈出的地方设置时间(200)和字母(.ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz),而后点击ok即可。
当前文章:java补全代码 代码补全是什么
URL地址:http://ybzwz.com/article/docogdo.html