java个人信息完善代码 java个人信息完善代码有哪些
在JAVA程序中输出自己的基本信息(姓名和年龄),会的请给个代码!
public class student
在网站制作、成都做网站中从网站色彩、结构布局、栏目设置、关键词群组等细微处着手,突出企业的产品/服务/品牌,帮助企业锁定精准用户,提高在线咨询和转化,使成都网站营销成为有效果、有回报的无锡营销推广。创新互联专业成都网站建设10余年了,客户满意度97.8%,欢迎成都创新互联客户联系。
{public static void main(String args[])
{
int iB=20;
String iA="姓名"; //这行如果是字符串要定义为String类型,而且赋值时要加上双引号。
System.out.println("姓名是:"+iA+"年龄"+iB); //这行里的逗号改为加号,否则报错。
}
}
一看就是新手入门,建议别着急写代码,现看看java的语法,java不是很难,慢慢来:)
简单个人简历java录入程序 代码
我帮你写了那些JAVA代码了,效果包你满意!呵呵……
至于网页的代码嘛,这里就不贴了。你要的话HI我吧^_^。
JAVA代码如下:
import java.awt.BorderLayout;
import javax.swing.*;
import java.awt.Dimension;
import java.awt.Rectangle;
public class MyLuRu extends JFrame {
private static final long serialVersionUID = 1L;
private JPanel jContentPane = null;
private JLabel jLabel = null;
private JLabel jLabel1 = null;
private JLabel jLabel2 = null;
private JLabel jLabel3 = null;
private JTextField jTextField = null;
private JRadioButton jRadioButton = null;
private JRadioButton jRadioButton1 = null;
private JComboBox jComboBox = null;
private JComboBox jComboBox1 = null;
private JButton jButton = null;
private JButton jButton1 = null;
private JTextArea jTextArea = null;
private ButtonGroup mybg=new ButtonGroup();
/**
* This is the default constructor
*/
public MyLuRu() {
super();
initialize();
}
/**
* This method initializes this
*
* @return void
*/
private void initialize() {
this.setSize(268, 407);
this.setContentPane(getJContentPane());
this.setTitle("录入");
this.addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent e) {
System.exit(0);
}
});
this.setVisible(true);
}
/**
* This method initializes jContentPane
*
* @return javax.swing.JPanel
*/
private JPanel getJContentPane() {
if (jContentPane == null) {
jLabel3 = new JLabel();
jLabel3.setBounds(new Rectangle(16, 150, 65, 18));
jLabel3.setText("文化程度:");
jLabel2 = new JLabel();
jLabel2.setBounds(new Rectangle(16, 108, 39, 18));
jLabel2.setText("专业:");
jLabel1 = new JLabel();
jLabel1.setBounds(new Rectangle(16, 66, 39, 18));
jLabel1.setText("性别:");
jLabel = new JLabel();
jLabel.setBounds(new Rectangle(16, 24, 39, 18));
jLabel.setText("姓名:");
jContentPane = new JPanel();
jContentPane.setLayout(null);
jContentPane.add(jLabel, null);
jContentPane.add(jLabel1, null);
jContentPane.add(jLabel2, null);
jContentPane.add(jLabel3, null);
jContentPane.add(getJTextField(), null);
jContentPane.add(getJRadioButton(), null);
jContentPane.add(getJRadioButton1(), null);
mybg.add(jRadioButton);
mybg.add(jRadioButton1);
jContentPane.add(getJComboBox(), null);
jContentPane.add(getJComboBox1(), null);
jContentPane.add(getJButton(), null);
jContentPane.add(getJButton1(), null);
jContentPane.add(getJTextArea(), null);
}
return jContentPane;
}
/**
* This method initializes jTextField
*
* @return javax.swing.JTextField
*/
private JTextField getJTextField() {
if (jTextField == null) {
jTextField = new JTextField();
jTextField.setBounds(new Rectangle(61, 24, 180, 18));
}
return jTextField;
}
/**
* This method initializes jRadioButton
*
* @return javax.swing.JRadioButton
*/
private JRadioButton getJRadioButton() {
if (jRadioButton == null) {
jRadioButton = new JRadioButton();
jRadioButton.setBounds(new Rectangle(61, 62, 38, 26));
jRadioButton.setText("男");
}
return jRadioButton;
}
/**
* This method initializes jRadioButton1
*
* @return javax.swing.JRadioButton
*/
private JRadioButton getJRadioButton1() {
if (jRadioButton1 == null) {
jRadioButton1 = new JRadioButton();
jRadioButton1.setBounds(new Rectangle(117, 62, 38, 26));
jRadioButton1.setText("女");
}
return jRadioButton1;
}
/**
* This method initializes jComboBox
*
* @return javax.swing.JComboBox
*/
private JComboBox getJComboBox() {
if (jComboBox == null) {
String[] strcb={"计算机","电子","工商"};
jComboBox = new JComboBox(strcb);
jComboBox.setBounds(new Rectangle(62, 108, 93, 18));
}
return jComboBox;
}
/**
* This method initializes jComboBox1
*
* @return javax.swing.JComboBox
*/
private JComboBox getJComboBox1() {
if (jComboBox1 == null) {
String[] strcb2={"大专","本科","硕士","博士"};
jComboBox1 = new JComboBox(strcb2);
jComboBox1.setBounds(new Rectangle(92, 150, 125, 18));
}
return jComboBox1;
}
/**
* This method initializes jButton
*
* @return javax.swing.JButton
*/
private JButton getJButton() {
if (jButton == null) {
jButton = new JButton();
jButton.setBounds(new Rectangle(66, 181, 60, 28));
jButton.setText("提交");
jButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
String strname=jTextField.getText();
String strsex="男";
if(jRadioButton1.isSelected()){
strsex="女";
}
String strzy=jComboBox.getSelectedItem().toString();
String strwh=jComboBox1.getSelectedItem().toString();
jTextArea.setText("姓名:"+strname+"\r\n"+"性别:"+strsex+"\r\n"+"专业:"+strzy+"\r\n"+"文化:"+strwh);
}
});
}
return jButton;
}
/**
* This method initializes jButton1
*
* @return javax.swing.JButton
*/
private JButton getJButton1() {
if (jButton1 == null) {
jButton1 = new JButton();
jButton1.setBounds(new Rectangle(158, 181, 60, 28));
jButton1.setText("取消");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
System.exit(0);
}
});
}
return jButton1;
}
/**
* This method initializes jTextArea
*
* @return javax.swing.JTextArea
*/
private JTextArea getJTextArea() {
if (jTextArea == null) {
jTextArea = new JTextArea();
jTextArea.setBounds(new Rectangle(16, 225, 229, 130));
}
return jTextArea;
}
public static void main(String args[]){
new MyLuRu();
}
}
效果如下图:
编写一个简单的java程序显示个人信息:姓名,性别,出生年月,爱好?
public class MyInfo {
public static void main(String []args) {
System.out.println("你好,以下是我的个人信息:");
System.out.println("姓名:李刚");
System.out.println("性别:女");
System.out.println("出生年月:1998-08");
System.out.println("爱好:上网");}
}
编写一个JAVA程序,显示你的个人档案!
/*首先定义一个方法类*/
class method{
public String name;
public String sex;
public int age;
/*这里还可以定义很多关于你的档案信息成员变量*/
/*下面这两个是构造方法*/
method(){
name="";
sex="";
age=0;
}
method(String name,String sex,int age){
this.name=name;
this.sex=sex;
this.age=age;
}
/*下面写方法*/
String getName(String name){
return name;
}
String getSex(String sex){
return sex;
}
int getAge(int age){
return age;
}
}
/*写一个测试类*/
public class Test{
public static void main(String args[]){
method a=new method("浅浅de夕阳","男",20);
System.out.println("姓名:"+a.getName());
System.out.println("性别:"+a.getSex());
System.out.println("年龄:"+a.getAge());
}
}
我写的稍微复杂了点,但是也就完善了点,写那几个get方法,是为了更完整,那样就算是你的成员变量改为私有的,在后面通过调用get方法也能返回变量的值。
编写java应用程序,选择合适的数据类型定义个人信息,并在命令行用一个输出语句分行输出
首先在任一目录保存以下代码
编译代码:javac PersonInfo.class
执行代码:java PersonInfo
代码输出效果如下:
id = 001, name = 张三, sex = 男, 年龄 = 12, 身份证 = 140421198809021102
id = 002, name = 李四, sex = 女, 年龄 = 25, 身份证 = 280421198809022103
id = 003, name = 王五, sex = 男, 年龄 = 33, 身份证 = 355421198809021104
id = 004, name = 赵六, sex = 女, 年龄 = 17, 身份证 = 472421198809021105
import java.util.ArrayList;
import java.util.List;
public class PersonInfo{
private String id; //id
private String name; //姓名
private int sex; //性别
private int age; //年龄
private String idCard; //身份证
@Override
public String toString() {
return "id = " + getId() + ", name = "
+ getName() + ", sex = " + (getSex()==0?"男":"女")
+ ", 年龄 = " + getAge() + ", 身份证 = " + getIdCard();
}
public PersonInfo(String id, String name, int sex, int age, String idCard) {
this.id = id;
this.name = name;
this.sex = sex;
this.age = age;
this.idCard = idCard;
}
public static void main(String[] args) {
PersonInfo p1 = new PersonInfo("001", "张三", 0, 12, "140421198809021102");
PersonInfo p2 = new PersonInfo("002", "李四", 1, 25, "280421198809022103");
PersonInfo p3 = new PersonInfo("003", "王五", 0, 33, "355421198809021104");
PersonInfo p4 = new PersonInfo("004", "赵六", 1, 17, "472421198809021105");
ListPersonInfo personList = new ArrayListPersonInfo();
personList.add(p1);
personList.add(p2);
personList.add(p3);
personList.add(p4);
for(PersonInfo p : personList){
System.out.println(p);
}
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getSex() {
return sex;
}
public void setSex(int sex) {
this.sex = sex;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public String getIdCard() {
return idCard;
}
public void setIdCard(String idCard) {
this.idCard = idCard;
}
}
文章标题:java个人信息完善代码 java个人信息完善代码有哪些
文章源于:http://azwzsj.com/article/hjioeh.html