第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

java中%1$s什么意思啊?

java中%1$s什么意思啊?

瀟湘沐 2019-07-15 08:04:48
import java.awt.*;import java.awt.event.*;import javax.swing.*;public class Example extends JFrame {static Example frm=new Example();static JTextField txf=new JTextField();static TextArea txa=new TextArea("",8,14,TextArea.SCROLLBARS_VERTICAL_ONLY);static JTextArea txa1=new JTextArea();public static void main(String[] args) {Button btn=new Button("抽取");Button btn1=new Button("退出");frm.setTitle(" ");frm.setSize(600,400);frm.setLayout(null);frm.setBackground(Color.gray);frm.setResizable(false);btn.setBounds(500,250,50,30);btn1.setBounds(500,320,50,30);txf.setBounds(20,50,200,30);txa.setBounds(20,100,200,250);txa1.setBounds(240,50,200,300);txa1.setEditable(false);txa.setEditable(false);txa.setBackground(Color.white);txf.addKeyListener(new Ky());btn.addActionListener(new Act());frm.add(btn);frm.add(btn1);frm.add(txf);frm.add(txa);frm.add(txa1);frm.setVisible(true);}static class Ky implements KeyListener{public void keyPressed(KeyEvent a){if(a.getKeyChar()!='\n')return;String name=txf.getText();if(name.isEmpty())return;txa.append(name+"\n");txa.selectAll();}public void keyReleased(KeyEvent e) { }public void keyTyped(KeyEvent e) {}}static class Act implements ActionListener{public void actionPerformed(ActionEvent a){String perstring=txa.getText();String[] personnelArray=perstring.split("\n");int index=(int)(Math.random()*personnelArray.length);String formatArg="本次抽取觀眾人員:\n\t%1$s\n成為本次觀眾抽獎(jiǎng)的大獎(jiǎng)得主。"+"\n\n我們將為%1$s頒發(fā):\n\t過(guò)期的酸牛奶二十箱。";String info=String.format(formatArg,personnelArray[index]);txa1.setText(info);}}}
查看完整描述

2 回答

?
神不在的星期二

TA貢獻(xiàn)1963條經(jīng)驗(yàn) 獲得超6個(gè)贊

被格式化的參數(shù)索引%1$s和%2$s分別表示第一位和第二位占位符,$s表示是字符串

查看完整回答
反對(duì) 回復(fù) 2019-07-16
  • 2 回答
  • 0 關(guān)注
  • 1063 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)