導航:首頁 > 編程語言 > java題

java題

發布時間:2022-02-08 13:51:53

java題目

1.................程序輸入非數字%結束
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Du {

public static void main(String[] args) {
double[] numbers = getNumbersFromInput();

Arrays.sort(numbers);

double max = numbers[numbers.length - 1];
double min = numbers[0];

System.out.println("Max is: " + max);
System.out.println("Min is: " + min);
}

private static double[] getNumbersFromInput() {
List<Double> list = new ArrayList<Double>();

String input = "";
final String EXIT = "%";

while(true){
System.out.print("Please input a number:");

Scanner scanner = new Scanner(System.in);

try{
input = scanner.next().trim();

if(input.equals(EXIT)){
break;
}

list.add(Double.parseDouble(input));
}catch(NumberFormatException nbFmtExp){
System.out.println("Only numbers allowed. Please input again!");
continue;
}
}

double[] numbers = new double[list.size()];

for(int i = 0; i < list.size(); i++){
numbers[i] = list.get(i).doubleValue();
}

return numbers;
}
}

-----------------------
Please input a number:35
Please input a number:ab
Only numbers allowed. Please input again!
Please input a number:68
Please input a number:5
Please input a number:96
Please input a number:35.3
Please input a number:2
Please input a number:129
Please input a number:652
Please input a number:%
Max is: 652.0
Min is: 2.0

2.......................
import java.util.Random;

public class Second {

public static void main(String[] args) {

int[][] nums = new int[4][5];

Random rand = new Random();//測試用隨機數生成數組

for(int i = 0; i < nums.length; i++){
for(int j = 0; j < nums[i].length; j++){
nums[i][j] = rand.nextInt(500);//方便測試,限制小於500
}
}

MinItem min = new MinItem(nums[0][0], 0, 0);

for(int i = 0; i < nums.length; i++){
for(int j = 0; j < nums[i].length; j++){
System.out.print(nums[i][j] + "\t");//輸出數組
if(min.getValue() > nums[i][j]){
min = new MinItem(nums[i][j], i, j);
}
}

System.out.println();
}

System.out.println("Min is " + min.getValue()
+ ". Row: " + (min.getRow() + 1)
+ ", Column : " + (min.getCol() + 1));

}
}

class MinItem {
private int row;
private int col;
private int value;

public MinItem(int value, int row, int col){
this.value = value;
this.row = row;
this.col = col;
}

public int getValue() {
return value;
}

public int getCol() {
return col;
}

public int getRow() {
return row;
}

}
---------------------------
241 46 112 113 177
320 82 482 381 329
78 435 354 399 53
381 5 354 478 198
Min is 5. Row: 4, Column : 2

㈡ java試題

start方法哈

給你個例子哈

import java.applet.Applet;
import java.awt.Graphics;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

public class AppletAnimation extends Applet implements Runnable {
int frameNumber = -1;

int delay = 100;

Thread animatorThread;

boolean frozen = false;

public void init() {
String str;
addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent e) {
if (frozen) {
frozen = false;
start();
} else {
frozen = true;
stop();
}
}
});
}

public void start() {
if (!frozen) {
if (animatorThread == null) {
animatorThread = new Thread(this);
}
animatorThread.start();
}
}

public void stop() {
animatorThread = null;
}

public void run() {
Thread.currentThread().setPriority(Thread.MIN_PRIORITY);

long startTime = System.currentTimeMillis();

Thread currentThread = Thread.currentThread();

while (currentThread == animatorThread) {
frameNumber++;

repaint();

try {
startTime += delay;
Thread.sleep(100);
} catch (InterruptedException e) {
break;
}
}
}

public void paint(Graphics g) {
g.drawString("Frame " + frameNumber, 0, 30);
}
}

㈢ java題

package com.test;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
* 字元串工具類
*
* @author 劉逸暉
*
*/
public class StringUtil {
/**
* 刪除字元串數組中重復的成員
*
* @param src
* 原數組
* @return 刪除重復成員後的數組
*/
public static String[] trim(String[] src) {
// 我這個方法估計也不是效率最高的,只是想到可以這樣寫就這樣寫了。
List<String> srcList = new ArrayList<>(Arrays.asList(src));
// 注意,不能直接用數組轉化出來的那個ArrayList對象,因為用數組轉化出來的那個ArrayList對象做某些操作的時候會報錯。
for (int i = 0; i < srcList.size(); i++) {
String str = srcList.get(i);
// 注意,在這里別用高級for循環,因為在使用高級for循環的時候不能修改集合或數組中的元素。
while (srcList.remove(str)) {
}
srcList.add(str);
}
return srcList.toArray(new String[srcList.size()]);
}
/**
* 字元反轉
*
* @param src
* 原文本
* @return 反轉後的文本
*/
public static String reverse(String src) {
return new StringBuffer(src).reverse().toString();
}
/**
* 統計字元串中單詞的個數。
*
* @param str
* 原文本
* @return 單詞個數
*/
public static int split(String str) {
return str.split("[^A-Za-z]+").length;
}
}

package com.test;
import java.util.Arrays;
/**
* 我的測試類
*
* @author 劉逸暉
*
*/
public class MyTest {
public static void main(String[] args) {
String[] srcArray = new String[] { "a", "b", "c", "a", "a", "d", "c",
"b" };
System.out.println("原字元串數組:\r\n" + Arrays.toString(srcArray));
System.out.println("去除重復成員後的數組:\r\n"
+ Arrays.toString(StringUtil.trim(srcArray)));
String srcStr = "hello world";
System.out.println("原文本:\r\n" + srcStr);
System.out.println("反轉後的文本:\r\n" + StringUtil.reverse(srcStr));
System.out.println("文本中的單詞數:\r\n" + StringUtil.split(srcStr));
}
}

㈣ Java題目

倆題連著推送給我了,那就都給你寫了,望採納

//測試類
publicclassMingXingTest{
publicstaticvoidmain(String[]args){
MingXingmingXing=newMingXing();
MingXing.show();
/*
輸出結果為
明星姓名:趙麗穎
明星性別:女
明星年齡:18
明星代表作:花千骨、楚喬傳、陸貞傳奇、杉杉來了、知否知否應是綠肥紅瘦、乘風破浪、西遊記女兒國
*/
MingXingmx=newMingXing("楊紫","女",18,"家有兒女、戰長沙、歡樂頌、歡樂頌2、香蜜沉沉燼如霜、青雲志、親愛的,熱愛的、餘生,請多指教");
mx.show();
/*
輸出結果為
明星姓名:楊紫
明星性別:女
明星年齡:18
明星代表作:家有兒女、戰長沙、歡樂頌、歡樂頌2、香蜜沉沉燼如霜、青雲志、親愛的,熱愛的、餘生,請多指教
*/
}
}


//明星類
publicclassMingXing{
//默認初始值
privateStringname="趙麗穎";
privateStringsex="女";
privateintage=18;
privateStringdaiBiaoZuo="花千骨、楚喬傳、陸貞傳奇、杉杉來了、知否知否應是綠肥紅瘦、乘風破浪、西遊記女兒國";

//空構造方法
publicMingXing(){}

//自己賦值的構造方法
publicMingXing(Stringname,Stringsex,intage,StringdaiBiaoZuo){
this.name=name;
this.sex=sex;
this.age=age;
this.daiBiaoZuo=daiBiaoZuo;
}

publicvoidshow(){
System.out.println("明星姓名:"+name);
System.out.println("明星性別:"+sex);
System.out.println("明星年齡:"+age);
System.out.println("明星代表作:"+daiBiaoZuo);
}

//set、get方法
publicvoidsetName(Stringname){
this.name=name;
}
publicStringgetName(){
returnname;
}

//TODO

}

㈤ JAVA題目

1.
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;

public class Count extends JFrame {

private static final long serialVersionUID = 1L;

public static void main(String args[]) {
try {
Count frame = new Count();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}

public Count() {
super();
setTitle("Count");
setBounds(100, 100, 200, 200);
getContentPane().setLayout(null);
setResizable(false);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

final JButton btn = new JButton();
btn.setText("0");
btn.addActionListener(new ActionListener() {
int i = 1;
public void actionPerformed(ActionEvent arg0) {
btn.setText(String.valueOf(i));
i++;
}
});
btn.setBounds(50, 71, 99, 23);
getContentPane().add(btn);
}
}

---------------------
2.
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;

import javax.swing.JFrame;
import javax.swing.JTextField;

public class Input extends JFrame {

private static final long serialVersionUID = 1L;

private JTextField txt;

public static void main(String args[]) {
try {
Input frame = new Input();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}

public Input() {
super();
setTitle("Input");
setResizable(false);
getContentPane().setLayout(null);
setBounds(100, 100, 200, 200);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

txt = new JTextField();
txt.setBounds(48, 61, 90, 21);
getContentPane().add(txt);
txt.addKeyListener(new KeyAdapter(){
public void keyPressed(KeyEvent e){
if(e.getKeyCode()==KeyEvent.VK_ENTER){
if(txt.getText().matches("\\d+")){
int sum = 0;
int end = Integer.parseInt(txt.getText());
for(int i = 1;i<=end;i++){
sum = sum + i;
}
txt.setText(String.valueOf(sum));
}else{
txt.setText("輸入錯誤,重新輸入");
}
}else{
return;
}
}
});
}
}

㈥ 一道JAVA題

下面是以前寫的一個萬年歷程序,lz可以參考。
以下是兩個類,請樓主分別存成兩個java文件:
其中
MainFrame.java是顯示日歷程序,Clock.java是日歷計算程序。編譯後運行MainFrame這個類即可。

1.MainFrame.java
---
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.GridLayout;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Date;
import java.util.Calendar;

import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;

public class MainFrame extends JFrame {
/** *//**
*
*/
private static final long serialVersionUID = 1L;
JPanel panel = new JPanel(new BorderLayout());
JPanel panel1 = new JPanel();
JPanel panel2 = new JPanel(new GridLayout(7, 7));
JPanel panel3 = new JPanel();
JLabel[] label = new JLabel[49];
JLabel y_label = new JLabel("年份");
JLabel m_label = new JLabel("月份");
JComboBox com1 = new JComboBox();
JComboBox com2 = new JComboBox();
int re_year, re_month;
int x_size, y_size;
String year_num;
Calendar now = Calendar.getInstance(); // 實例化Calendar

MainFrame() {
super("萬年歷");
setSize(300, 350);
x_size = (int) (Toolkit.getDefaultToolkit().getScreenSize().getWidth());
y_size = (int) (Toolkit.getDefaultToolkit().getScreenSize().getHeight());
setLocation((x_size - 300) / 2, (y_size - 350) / 2);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
panel1.add(y_label);
panel1.add(com1);
panel1.add(m_label);
panel1.add(com2);
for (int i = 0; i < 49; i++) {
label[i] = new JLabel("", JLabel.CENTER);// 將顯示的字元設置為居中
panel2.add(label[i]);
}
panel3.add(new Clock(this));
panel.add(panel1, BorderLayout.NORTH);
panel.add(panel2, BorderLayout.CENTER);
panel.add(panel3, BorderLayout.SOUTH);
panel.setBackground(Color.white);
panel1.setBackground(Color.white);
panel2.setBackground(Color.white);
panel3.setBackground(Color.white);
Init();
com1.addActionListener(new ClockAction());
com2.addActionListener(new ClockAction());

setContentPane(panel);
setVisible(true);
setResizable(false);
}

class ClockAction implements ActionListener {
public void actionPerformed(ActionEvent arg0) {
int c_year, c_month, c_week;
c_year = Integer.parseInt(com1.getSelectedItem().toString()); // 得到當前所選年份
c_month = Integer.parseInt(com2.getSelectedItem().toString()) - 1; // 得到當前月份,並減1,計算機中的月為0-11
c_week = use(c_year, c_month); // 調用函數use,得到星期幾
Resetday(c_week, c_year, c_month); // 調用函數Resetday
}
}

public void Init() {
int year, month_num, first_day_num;
String log[] = { "日", "一", "二", "三", "四", "五", "六" };
for (int i = 0; i < 7; i++) {
label[i].setText(log[i]);
}
for (int i = 0; i < 49; i = i + 7) {
label[i].setForeground(Color.red); // 將星期日的日期設置為紅色
}
for (int i = 6; i < 49; i = i + 7) {
label[i].setForeground(Color.green);// 將星期六的日期設置為綠色
}
for (int i = 1; i < 10000; i++) {
com1.addItem("" + i);
}
for (int i = 1; i < 13; i++) {
com2.addItem("" + i);
}
month_num = (int) (now.get(Calendar.MONTH)); // 得到當前時間的月份
year = (int) (now.get(Calendar.YEAR)); // 得到當前時間的年份
com1.setSelectedIndex(year - 1); // 設置下拉列表顯示為當前年
com2.setSelectedIndex(month_num); // 設置下拉列表顯示為當前月
first_day_num = use(year, month_num);
Resetday(first_day_num, year, month_num);
}

public int use(int reyear, int remonth) {
int week_num;
now.set(reyear, remonth, 1); // 設置時間為所要查詢的年月的第一天
week_num = (int) (now.get(Calendar.DAY_OF_WEEK));// 得到第一天的星期
return week_num;
}

@SuppressWarnings("deprecation")
public void Resetday(int week_log, int year_log, int month_log) {
int month_day_score; // 存儲月份的天數
int count;
month_day_score = 0;
count = 1;

Date date = new Date(year_log, month_log + 1, 1); // now
Calendar cal = Calendar.getInstance();
cal.setTime(date);
cal.add(Calendar.MONTH, -1); // 前個月
month_day_score = cal.getActualMaximum(Calendar.DAY_OF_MONTH);// 最後一天

for (int i = 7; i < 49; i++) { // 初始化標簽
label[i].setText("");
}
week_log = week_log + 6; // 將星期數加6,使顯示正確
month_day_score = month_day_score + week_log;
for (int i = week_log; i < month_day_score; i++, count++) {
label[i].setText(count + "");
}
}

public static void main(String[] args) {
JFrame.(true);
new MainFrame();
}
}
2.Clock.java
-----
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.GridLayout;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Date;
import java.util.Calendar;

import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;

//顯示時間的類:Clock

/** *//**
* Clock.java
* Summary 數字時間顯示
* Created on
* @author
* remark
*/

import java.awt.Canvas;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.text.SimpleDateFormat;
import java.util.Calendar;
class Clock extends Canvas implements Runnable{
/** *//**
*
*/
private static final long serialVersionUID = 3660124045489727166L;
MainFrame mf;
Thread t;
String time;
public Clock(MainFrame mf){
this.mf=mf;
setSize(280,40);
setBackground(Color.white);
t=new Thread(this); //實例化線程
t.start(); //調用線程
}
public void run(){
while(true){
try{
Thread.sleep(1000); //休眠1秒鍾
}catch(InterruptedException e){
System.out.println("異常");
}
this.repaint(100);
}
}
public void paint(Graphics g){
Font f=new Font("宋體",Font.BOLD,16);
SimpleDateFormat SDF=new SimpleDateFormat("yyyy'年'MM'月'dd'日'HH:mm:ss");//格式化時間顯示類型
Calendar now=Calendar.getInstance();
time=SDF.format(now.getTime()); //得到當前日期和時間
g.setFont(f);
g.setColor(Color.orange);
g.drawString(time,45,25);
}
}

㈦ Java題目目

packageorg.test;

importjava.util.ArrayList;
importjava.util.List;

publicclassQuestion5{

publicstaticvoidmain(String[]args){
int[]oldArr={1,3,4,5,0,0,6,6,0,5,4,7,6,7,0,5};
List<Integer>list=newArrayList<>();
for(inti:oldArr){
if(i!=0)
list.add(i);
}
Integer[]newArr=list.toArray(newInteger[list.size()]);
System.out.print("{");
for(inti=0;i<newArr.length;i++){
if(i==0){
System.out.print(i);
}else{
System.out.print(","+i);
}
}
System.out.print("}");
}

}
packageorg.test;

importjava.util.ArrayList;
importjava.util.Collections;
importjava.util.LinkedList;
importjava.util.List;

{

publicQuestion6(intplayerAmount){
this.playerAmount=playerAmount;
}
privateintplayerAmount;
privateLinkedList<Card>cardHeap=newLinkedList<>();

privateList<Player>players=newArrayList<>(playerAmount);

publicvoidaddPlayers(Playerp){
if(players.size()<playerAmount){
players.add(p);
}else{
System.out.println("therearetoomanyplayers,cannotaddanymore!");
return;
}
}

publicvoidinit(){
List<Card>list=newArrayList<>();
//ifjokersarenotnecessary,justremovethe4linesbelow.
// CardredJoker=newCard(0,Color.RED_JOKER);
// CardblackJoker=newCard(0,Color.BLACK_JOKER);
// list.add(redJoker);
// list.add(blackJoker);

for(inti=1;i<=13;i++){
for(intj=0;j<4;j++){
Cardcard=newCard(i,getColorByNum(j));
list.add(card);
}
}
System.out.println("shuffling...");
Collections.shuffle(list);
cardHeap.addAll(list);
}

privateColorgetColorByNum(intnum){
Colorres=null;
switch(num){
case0:res=Color.RED_HAERT;break;
case1:res=Color.BLACK_HAERT;break;
case2:res=Color.LABEL;break;
case3:res=Color.FLOWER;break;
}
returnres;
}

@Override
publicvoidrun(){
//getcardfromcardheap
if(players.size()==0){
System.out.println("noplayers!");
return;
}
System.out.println("beginplaying!");
while(cardHeap.size()>0){
deal();
}
for(Playerp:players){
System.out.println(p.getPlayerName());
Stringinfo=p.hand.showCards()+",totalamount:"+p.hand.getCardsAmount();
System.out.println(info);
}
}

publicvoiddeal(){
for(Playerp:players){
synchronized(cardHeap){
p.hand.getCard(cardHeap.pollFirst());
}
}
}

publicstaticvoidmain(String[]args){
Question6q=newQuestion6(3);
q.init();//shufflecards
Playerp1=newPlayer("p1");//createplayer1
Playerp2=newPlayer("p2");//createplayer2
Playerp3=newPlayer("p3");//createplayer3
//addplayerstolist
q.addPlayers(p1);
q.addPlayers(p2);
q.addPlayers(p3);
Threadth=newThread(q);
//startgettingcards
th.start();
}
}

classHand{
privateList<Card>cards=newArrayList<>();

publicvoidgetCard(Cardcard){
if(card!=null){
cards.add(card);
}
}

publicvoiddropCard(Cardcard){
cards.remove(card);
}

publicintgetCardsAmount(){
returncards.size();
}

publicStringshowCards(){
StringBuildershow=newStringBuilder();
for(inti=0;i<cards.size();i++){
Cardcard=cards.get(i);
Stringinfo=card.getNum()+"("+card.getColor()+")";
if(i==0){
show.append(info);
}else{
show.append(","+info);
}
}
returnshow.toString();
}
}

classPlayer{
publicHandhand=newHand();
privateStringplayerName;
publicStringgetPlayerName(){
returnplayerName;
}
publicvoidsetPlayerName(StringplayerName){
this.playerName=playerName;
}
publicPlayer(StringplayerName){
super();
this.playerName=playerName;
}
}

classCard{
privateintnum;
privateColorcolor;
publicintgetNum(){
returnnum;
}
publicvoidsetNum(intnum){
this.num=num;
}
publicColorgetColor(){
returncolor;
}
publicvoidsetColor(Colorcolor){
this.color=color;
}
publicCard(intnum,Colorcolor){
super();
this.num=num;
this.color=color;
}
}

enumColor{
RED_HAERT,
BLACK_HAERT,
LABEL,
FLOWER,
RED_JOKER,
BLACK_JOKER;
}


packageorg.test;

publicclassQuestion7{

publicStringdoConvert(Integernum){
StringnumString=num.toString();
intlength=numString.length();
StringreturnString="";
if(length>4){
return"wrongnumber,themaximumlengthis4";
}
switch(length){
case1:returnString=numberConverter(numString);break;
case2:
StringfirstNum2=numString.substring(0,1);
StringsecondNum2=numString.substring(1);
returnString=processer2(firstNum2,secondNum2);
break;
case3:
StringfirstNum3=numString.substring(0,1);
StringsecondNum3=numString.substring(1,2);
StringthirdNum3=numString.substring(2);
returnString=processer3(firstNum3,secondNum3,thirdNum3);
break;
case4:
StringfirstNum4=numString.substring(0,1);
StringsecondNum4=numString.substring(1,2);
StringthirdNum4=numString.substring(2,3);
StringfourthNum4=numString.substring(3);
if(!"0".equals(secondNum4)){
Stringtmp=processer3(secondNum4,thirdNum4,fourthNum4);
returnString=numberConverter(firstNum4)+"仟"+tmp;
}else{
if(!"0".equals(thirdNum4)){
Stringtmp=processer2(thirdNum4,fourthNum4);
returnString=numberConverter(firstNum4)+"仟零"+tmp;
}else{
if(!"0".equals(fourthNum4)){
returnString=numberConverter(firstNum4)+"仟零"+
numberConverter(fourthNum4);
}else{
returnString=numberConverter(firstNum4)+"仟";
}
}
}
break;
}
returnreturnString+"圓";
}

privateStringprocesser3(Stringfirst,Stringsecond,Stringthird){
StringreturnString="";
if("0".equals(third)&&"0".equals(second)){
returnString=numberConverter(first)+"佰";
}elseif("0".equals(third)&&!"0".equals(second)){
returnString=numberConverter(first)+"佰"+numberConverter(second)
+"拾";
}elseif(!"0".equals(third)&&"0".equals(second)&&!"0".equals(third)){
returnString=numberConverter(first)+"佰零"+numberConverter(third);
}else{
returnString=numberConverter(first)+"佰"+numberConverter(second)
+"拾"+numberConverter(third);
}
returnreturnString;
}
privateStringprocesser2(Stringfirst,Stringsecond){
StringreturnString="";
if("0".equals(second)){
returnString=numberConverter(first)+"拾";
}else{
returnString=numberConverter(first)+"拾"+
numberConverter(second);
}
returnreturnString;
}
privateStringnumberConverter(StringnumString){
StringreturnString="";
switch(numString){
case"0":returnString="零";break;
case"1":returnString="壹";break;
case"2":returnString="貳";break;
case"3":returnString="叄";break;
case"4":returnString="肆";break;
case"5":returnString="伍";break;
case"6":returnString="陸";break;
case"7":returnString="柒";break;
case"8":returnString="捌";break;
case"9":returnString="玖";break;
}
returnreturnString;
}

publicstaticvoidmain(String[]args){
Stringres=newQuestion7().doConvert(222);
System.out.println(res);
}
}

㈧ Java題!

輸出信息重寫了toString,輸出C語言成績直接用了變數。可以根據自己需要修改,望採納

publicclassStudent{
Stringname;
intage;
Stringsex;
intgrade;
int$class;
doublecMark;

publicStudent(Stringname,intage,intgrade,int$class,doublecMark){
this.name=name;
this.age=age;
this.grade=grade;
this.$class=$class;
this.cMark=cMark;
}
publicStringtoString(){
return"姓名:"+name+"性別:"+sex+"年齡:"+age+"年級:"+grade+"班級:"+$class;
}

}

publicclassStudentTest{
publicstaticvoidmain(String[]args){
Studentstu=newStudent("張三",18,3,32,99.5);
System.out.println(stu.toString());
System.out.println(stu.cMark);
}
}

㈨ JAVA試題

4.B 5.C 6.A 9.B 12.D 13.B 9.A 15.B 12.A 16.C 17.B 18.A 19.C 20.D 21.B 22.A 23.B 25.B 26.C

不要把錯誤概念教給初學者,這樣會誤導他們的。

㈩ Java題

大致寫了一下,基本功能滿足,望採納

publicclassMingXing{
privateStringname;
privateStringsex;
privateintage;
privateStringdaiBiaoZuo;

publicMingXing(Stringname,Stringsex,intage,StringdaiBiaoZuo){
this.name=name;
this.sex=sex;
this.age=age;
this.daiBiaoZuo=daiBiaoZuo;
}

publicvoidshow(){
System.out.println("明星姓名:"+name);
System.out.println("明星性別:"+sex);
System.out.println("明星年齡:"+age);
System.out.println("明星代表作:"+daiBiaoZuo);
}

//set、get方法
publicvoidsetName(Stringname){
this.name=name;
}
publicStringgetName(){
returnname;
}

//TODO

}
閱讀全文

與java題相關的資料

熱點內容
最強腦洞小游戲誰是程序員 瀏覽:852
三星手機如何互傳安全文件夾內容 瀏覽:97
高校plus網課平台源碼 瀏覽:479
javaswing詳解 瀏覽:918
高仿產品可以在什麼APp上賣 瀏覽:183
什麼app可以玩摩托車 瀏覽:881
python異常值的確定及處理方法 瀏覽:599
在vi編輯器中設置行號的命令是 瀏覽:56
phptoken生成演算法 瀏覽:751
存儲編程是什麼 瀏覽:33
visualfoxpro命令編寫 瀏覽:620
基於單片機的搶答器的設計 瀏覽:775
湖州兼職程序員攻略 瀏覽:108
關於政務雲介面伺服器的申請 瀏覽:186
網路通訊加密了會安全嗎 瀏覽:386
門禁卡加密了還能用嗎 瀏覽:911
樁基礎地梁加密 瀏覽:973
如何檢驗安卓機速度 瀏覽:227
python等級對應的內容 瀏覽:987
味道pdf 瀏覽:191