日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

java的主函数在哪_打开一个别人的文件,一堆.java, 怎么知道main函数在哪里?

發布時間:2025/3/15 编程问答 20 豆豆
生活随笔 收集整理的這篇文章主要介紹了 java的主函数在哪_打开一个别人的文件,一堆.java, 怎么知道main函数在哪里? 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

展開全部

向下邊用java開發的一個計32313133353236313431303231363533e78988e69d8331333236356634數器的程序

它的文件名用計算器.java

用記事本打開代碼如下:

import java.awt.*;

import java.awt.event.*;

import javax.swing.*;

import java.lang.*;

public class jsq {

JFrame f = new JFrame("計數器");

JMenuBar menubar1 = new JMenuBar();

JMenu menu1 = new JMenu("編輯");

JMenu menu2 = new JMenu("幫助");

JTextField text = new JTextField("", 10);

JButton bc = new JButton("清除");

JPanel p1 = new JPanel();

JPanel p2 = new JPanel();

FlowLayout fl = new FlowLayout(10, 10, 10);

JButton b1 = new JButton("1");

JButton b2 = new JButton("2");

JButton b3 = new JButton("3");

JButton bx = new JButton("*");

JButton b4 = new JButton("4");

JButton b5 = new JButton("5");

JButton b6 = new JButton("6");

JButton bch = new JButton("/");

JButton b7 = new JButton("7");

JButton b8 = new JButton("8");

JButton b9 = new JButton("9");

JButton bjj = new JButton("+");

JButton b0 = new JButton("0");

JButton bd = new JButton(".");

JButton bj = new JButton("-");

JButton bdy = new JButton("=");

public String shu1,shu2;

double add1;

char op;

private boolean hasdot=false ,hasfuhao=false; // 判斷小數點

//boolean hasfuhao = false; // 判斷是否有運算符號

private boolean panduan=false;

public jsq() {

}

public static void main(String args[]) {

jsq j1 = new jsq();

j1.go();

}

public void go() {

text.setHorizontalAlignment(JTextField.RIGHT);

menubar1.add(menu1);

menubar1.add(menu2);

f.setJMenuBar(menubar1);

f.getContentPane().add("North", p1);

f.getContentPane().add("Center", p2);

p1.add(text);

p1.add(bc);

p2.setLayout(fl);

p2.add(b1);

p2.add(b2);

p2.add(b3);

p2.add(bx);

p2.add(b4);

p2.add(b5);

p2.add(b6);

p2.add(bch);

p2.add(b7);

p2.add(b8);

p2.add(b9);

p2.add(bjj);

p2.add(b0);

p2.add(bd);

p2.add(bj);

p2.add(bdy);

bc.addActionListener(new JMenuHandler(10));

b1.addActionListener(new JMenuHandler(1));

b2.addActionListener(new JMenuHandler(2));

b3.addActionListener(new JMenuHandler(3));

b4.addActionListener(new JMenuHandler(4));

b5.addActionListener(new JMenuHandler(5));

b6.addActionListener(new JMenuHandler(6));

b7.addActionListener(new JMenuHandler(7));

b8.addActionListener(new JMenuHandler(8));

b9.addActionListener(new JMenuHandler(9));

b0.addActionListener(new JMenuHandler(0));

bd.addActionListener(new JMenuHandler2());

if (!panduan) { //第一次按這些按鈕,就進行JMenuhandler1()監聽

bx.addActionListener(new JMenuHandler1());

bch.addActionListener(new JMenuHandler1());

bjj.addActionListener(new JMenuHandler1());

bj.addActionListener(new JMenuHandler1());

}

else { //第二次按這些按鈕,等同于等于的作用

bx.addActionListener(new JMenuHandler3());

bch.addActionListener(new JMenuHandler3());

bjj.addActionListener(new JMenuHandler3());

bj.addActionListener(new JMenuHandler3());

}

// bdy.addActionListener(new JMenuHandler3());

f.setSize(220, 280);

f.setVisible(true);

}

class JMenuHandler

implements ActionListener {

private int ch;

public JMenuHandler(int select) {

ch = select;

}

public void actionPerformed(ActionEvent e) {

String s = e.getActionCommand();//得到所按的按鈕對應的值

switch (ch) {

case 10:

text.setText("");

hasdot = false;

hasfuhao = false;

panduan=false;

break;

case 0:

text.setText(text.getText() + s);

break;

case 1:

text.setText(text.getText() + s);

break;

case 2:

text.setText(text.getText() + s);

break;

case 3:

text.setText(text.getText() + s);

break;

case 4:

text.setText(text.getText() + s);

break;

case 5:

text.setText(text.getText() + s);

break;

case 6:

text.setText(text.getText() + s);

break;

case 7:

text.setText(text.getText() + s);

break;

case 8:

text.setText(text.getText() + s);

break;

case 9:

text.setText(text.getText() + s);

break;

}

}

}

class JMenuHandler1

implements ActionListener {//對運算符進行監聽

public JMenuHandler1() {

}

public void actionPerformed(ActionEvent e) {

if (text.getText().equals("")) {

text.setText("");

}

else

if(!hasfuhao){

op = e.getActionCommand().charAt(0); //取得輸入的運算符

if (!panduan) { //是第一次按此按鈕

shu1 = text.getText(); //對第一次輸入的數據進行記錄

panduan = true;

text.setText("");

}

else{

shu2=text.getText();

System.out.println(shu2);

}

//System.out.println(shu1);

hasfuhao = true; //不能再輸入運算符

hasdot = false; //可以再次輸入小數點

}

}

}

class JMenuHandler2

implements ActionListener {//對小數點進行監聽

//String ch1=text.getText();

public JMenuHandler2() {

}

public void actionPerformed(ActionEvent e) {

if(!text.getText().equals(""))

if (!hasdot) { //數中沒有小數點

String str;

str = text.getText() + e.getActionCommand();

text.setText(str); //顯示小數點

hasdot = true; //有小數點

}

}

}

class JMenuHandler3

implements ActionListener { //對等于號進行監聽

public JMenuHandler3() {

double add1 = Double.parseDouble(shu1); //把shu1由string型轉換成double型

System.out.println(add1);

}

double add1 = Double.parseDouble(shu1);

double shu2 = Double.parseDouble(text.getText());//類型轉換,同上

public void actionPerformed(ActionEvent e) {

switch (op) {

case '+':

add1 = add1 + shu2;

break;

case '-':

add1 = add1 - shu2;

break;

case '*':

add1 = add1 * shu2;

break;

case '/':

add1 = add1 / shu2;

break;

}

if(panduan){

hasfuhao = false; //可以重新輸入運算符

panduan = false;

}else{

op=e.getActionCommand().charAt(0);//新的運算符放到op中

hasfuhao=true;

}

hasdot = false; //可以重新輸入小數點

text.setText(add1 + ""); //強制類型轉換

}

}

}

在public static void main(String args[])出現main我們就可肯定它就main函數,一般出現main的是主函數。

已贊過

已踩過<

你對這個回答的評價是?

評論

收起

總結

以上是生活随笔為你收集整理的java的主函数在哪_打开一个别人的文件,一堆.java, 怎么知道main函数在哪里?的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。