java类的编程代码 java简单编程代码

Java编程(写出程序代码)写了一个代码 , 代码如下,可以进行参考
public class sum {
public static void main(String[] args) {
//创建一个Scanner的对象input
Scanner input = new Scanner(System.in);
//提示用户输入数据
System.out.print("请输入一个整数");
//将输入的值赋给n
int n = input.nextInt();
//定义变量接收计算后的和
int sum = 0;
//利用循环进行求和
for (int i = 0; i = n; i) {
sum =i;
}
//输出最后的和
System.out.println("从0一直到" n "的所有整数的和是:" sum);
}
}
java编程(写出程序代码)public class Test {
public static void main(String[] args) {
// 定义数组
int[][] array = new int[5][6];
// 生成随机数初始化数组
for (int i = 0; iarray.length; i) {
for (int j = 0; jarray[i].length; j) {
array[i][j] = (int) (40 * Math.random())10;
}
}
// 输出数组
for (int i = 0; iarray.length; i) {
for (int j = 0; jarray[i].length; j) {
System.out.print(array[i][j]"\t");
}
System.out.println(); // 换行
}
}
}
JAVA编程代码import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.*;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;
public class LoginFrame extends JFrame {
/**
*
*/
private static final long serialVersionUID = 2899557721654693611L;
final JTextField jt1 = new JTextField ();
final JTextField jt2 = new JTextField ();
public LoginFrame() {
this.setTitle("学生登陆");
this.setLayout(null);
this.setBounds(200, 200, 400, 300);
JButton jb1 = new JButton("登陆");
JButton jb2 = new JButton("退出");
jb1.setBounds(50, 230, 80, 20);
jb2.setBounds(270,230,80,20);
jt1.setBounds(170,80,100,20);
jt2.setBounds(170,170,100,20);
JLabel jl1 = new JLabel("用户名");
JLabel jl2 = new JLabel("密码");
jl1.setBounds(80, 80, 50, 20);
jl2.setBounds(80, 170, 50, 20);
add(jb1);
add(jb2);
add(jt1);
add(jt2);
add(jl1);
add(jl2);
this.setVisible(true);
this.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
// TODO Auto-generated method stub
setVisible(false);
System.exit(0);
}
});
jb1.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
new IntoTxt().intotex(jt1.getText(), jt2.getText());
}
});
jb2.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
setVisible(false);
System.exit(0);
}
});
}
public static void main(String[] args) {
LoginFrame lf = new LoginFrame();
}
}
class IntoTxt {
public void intotex(String name,String password) {
BufferedWriter bw;
File file = new File("D:/write.txt");
if(!file.exists()) {
try {
file.createNewFile();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
try {
bw = new BufferedWriter(new FileWriter(file,true));
bw.newLine();
bw.write("用户名是");
bw.write(name);
bw.write("密码是");
bw.write(password);
bw.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
java编程代码,要完整的代码,可以运行出来的 。谢谢!Course.java
public class Course {
private String name;//课程名
private String id; //编号
private String selectId; //选修课编号
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getSelectId() {
return selectId;
}
public void setSelectId(String selectId) {
this.selectId = selectId;
}

}
Java编程,萌新不知道错哪了,望大佬指正,代码及报错如下?大兄弟 , 你这笔误也太厉害了 。
看你的class B,这里面方法应该是setName 你写成了setHame
统样class B方法setChineseScore 你写成了setChineseSoore
【java类的编程代码 java简单编程代码】关于java类的编程代码和java简单编程代码的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站 。

    推荐阅读