欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

java中輸入性別的代碼 java輸入姓名代碼

編寫一個(gè)JAVA程序 輸入自己的姓名和年齡并輸出 怎么寫

在main里寫

橋西網(wǎng)站建設(shè)公司成都創(chuàng)新互聯(lián),橋西網(wǎng)站設(shè)計(jì)制作,有大型網(wǎng)站制作公司豐富經(jīng)驗(yàn)。已為橋西超過千家提供企業(yè)網(wǎng)站建設(shè)服務(wù)。企業(yè)網(wǎng)站搭建\外貿(mào)網(wǎng)站建設(shè)要多少錢,請找那個(gè)售后服務(wù)好的橋西做網(wǎng)站的公司定做!

String name;

String age;

Scanner sc=new Scanner(System.in);

System.out.println("輸入姓名");

name=sc.nextLine();

System.out.println("輸入年齡");

age=sc.nextLine();

System.out.println("姓名"+name);

System.out.println("年齡"+age);

sc.close();

擴(kuò)展資料:

JAVA程序的語言特點(diǎn):

1.簡單性

Java看起來設(shè)計(jì)得很像C++,但是為了使語言小和容易熟悉,設(shè)計(jì)豎嘩昌者們把C++語言中許多可用的特征去掉了,這些特征是一般程序員很少使用余扒的。例如,Java不支持go to語句,代之以提供break和continue語句以及異常處理。

Java還剔除了C++的操作符過載(overload)和多繼承特征,并且不使用主文件,免去了預(yù)處理程序。因?yàn)镴ava沒有結(jié)構(gòu),數(shù)組和串都是對象,所以不需要指針。

Java能夠自動處理對象的引用和間接引用,實(shí)現(xiàn)自動的無用單元收集,使用戶不必為存儲管理問題煩惱,能更多的時(shí)間和精力花在研發(fā)上。

2.面向?qū)ο?/p>

Java是一個(gè)面向?qū)ο蟮恼Z言。對程序員來說,這意味著要注意應(yīng)中的數(shù)據(jù)和操縱數(shù)據(jù)的方法(method)蘆局,而不是嚴(yán)格地用過程來思考。在一個(gè)面向?qū)ο蟮南到y(tǒng)中,類(class)是數(shù)據(jù)和操作數(shù)據(jù)的方法的集合。

數(shù)據(jù)和方法一起描述對象(object)的狀態(tài)和行為。每一對象是其狀態(tài)和行為的封裝。類是按一定體系和層次安排的,使得子類可以從超類繼承行為。在這個(gè)類層次體系中有一個(gè)根類,它是具有一般行為的類。Java程序是用類來組織的。

JAVA編程 通過文本行輸入學(xué)生姓名,通過單選按鈕選擇性別,復(fù)選框選擇課程,在文本框中顯示所填寫及選擇信

package helloworld;

import java.awt.*;

import javax.swing.*;

//import com.borland.jbcl.layout.XYLayout;

//import com.borland.jbcl.layout.*;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

public class Frame1 extends JFrame {

//XYLayout xYLayout1 = new XYLayout();

JLabel jLabel1 = new JLabel();

JRadioButton jRadioButton1 = new JRadioButton();

JRadioButton jRadioButton2 = new JRadioButton();

JButton jButton1 = new JButton();

JLabel jLabel2 = new JLabel();

JCheckBox jCheckBox1 = new JCheckBox();

JCheckBox jCheckBox2 = new JCheckBox();

JCheckBox jCheckBox3 = new JCheckBox();

public static void main(String[] args) {

Frame1 frame=new Frame1();

frame.setBounds(100, 100, 200, 300);

frame.setVisible(true);

}

public Frame1() {

try {

jbInit();

} catch (Exception exception) {

exception.printStackTrace();

}

}

private void jbInit() throws Exception {

//getContentPane().setLayout(xYLayout1);

getContentPane().setLayout(new BoxLayout(getContentPane(),BoxLayout.Y_AXIS));

jLabel1.setText("性掘明 別:"虛散滑);

//xYLayout1.setWidth(326);

//xYLayout1.setHeight(214);

jButton1.setText("提 交");

jButton1.addActionListener(new Frame1_jButton1_actionAdapter(this));

jRadioButton2.setText("女差臘");

jLabel2.setText("愛 好:");

jCheckBox1.setText("唱歌");

jCheckBox2.setText("跳舞");

jCheckBox3.setText("閱讀");

this.getContentPane().add(jLabel1);//, new XYConstraints(31, 60, 46, 21));

this.getContentPane().add(jRadioButton1);//,new XYConstraints(127, 60, -1, -1));

this.getContentPane().add(jRadioButton2);//,new XYConstraints(216, 60, -1, -1));

this.getContentPane().add(jLabel2);//, new XYConstraints(31, 111, -1, -1));

this.getContentPane().add(jCheckBox1);//, new XYConstraints(97, 106, -1, -1));

this.getContentPane().add(jCheckBox2);//,new XYConstraints(164, 106, -1, -1));

this.getContentPane().add(jCheckBox3);//,new XYConstraints(233, 106, -1, -1));

this.getContentPane().add(jButton1);//, new XYConstraints(124, 154, -1, -1));

jRadioButton1.setText("男");

jRadioButton1.setSelected(true);

ButtonGroup bg=new ButtonGroup();

bg.add(jRadioButton1);

bg.add(jRadioButton2);

}

public void jButton1_actionPerformed(ActionEvent e) {

System.out.println("性別:"+(jRadioButton1.isSelected()?jRadioButton1.getText():jRadioButton2.getText()));

if(jCheckBox1.isSelected()){

System.out.println(jCheckBox1.getText());

}

if(jCheckBox2.isSelected()){

System.out.println(jCheckBox2.getText());

}

if(jCheckBox3.isSelected()){

System.out.println(jCheckBox3.getText());

}

}

}

class Frame1_jButton1_actionAdapter implements ActionListener {

private Frame1 adaptee;

Frame1_jButton1_actionAdapter(Frame1 adaptee) {

this.adaptee = adaptee;

}

public void actionPerformed(ActionEvent e) {

adaptee.jButton1_actionPerformed(e);

}

}

網(wǎng)站名稱:java中輸入性別的代碼 java輸入姓名代碼
網(wǎng)頁鏈接:http://chinadenli.net/article37/dsphdpj.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供小程序開發(fā)服務(wù)器托管網(wǎng)站內(nèi)鏈微信小程序網(wǎng)站營銷

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

網(wǎng)站托管運(yùn)營