你说的java源代码是指编译成的class文件前的java文件。
十余年的仪征网站建设经验,针对设计、前端、开发、售后、文案、推广等六对一服务,响应快,48小时及时工作处理。成都全网营销的优势是能够根据用户设备显示端的尺寸不同,自动调整仪征建站的显示方式,使网站能够适用不同显示终端,在浏览器中调整网站的宽度,无论在任何一种浏览器上浏览网站,都能展现优雅布局与设计,从而大程度地提升浏览体验。创新互联建站从事“仪征网站设计”,“仪征网站推广”以来,每个客户项目都认真落实执行。
当我们运行.java文件时,它会被系统编译成.class文件,例如Test.java编译之后就是Test.class,
源文件就是指Test.java文件,
一般部署项目时,有.class文件就可以发布运行了,但是如果想修改这个系统,.class是不能修改的,要有.java文件才能修改
也可以上网去下反编译软件,就是能把.class文件大部分还原成.java文件的工具,但不是100%还原,而且如果不是正版的,小心有毒啊,什么的。
//都是从新手过来的,以下代码供参考
//1.
public class BankAccount {
private static String acctnum;
private static double money;
private static void showAcct() {
System.out.println("账号为: " + acctnum);
}
private static void showMoney() {
System.out.println("余额为: " + money);
}
public BankAccount(String acc, double m) {
this.acctnum = acc;
this.money = m;
}
public static void main(String[] args) {
BankAccount ba = new BankAccount("626600018888", 5000.00);
ba.showAcct();
ba.showMoney();
}
}
//2.
public class Triangle {
private static float a;
private static float b;
private static float c;
public Triangle(float a, float b, float c) {
this.a = a;
this.b = b;
this.c = c;
}
public static boolean judgeTriangle(float a, float b, float c) {
if ((a Math.abs(b - c) a b + c)
(b Math.abs(a - c) b a + c)
(c Math.abs(a - b) c a + b))
return true;
else
return false;
}
public float getCircumference() {
return this.a + this.b + this.c;
}
}
//3.
public class TestTriangle {
public static void main(String[] args) {
Triangle t = new Triangle(5.3f,7.8f,9.3f);
if(t.judgeTriangle(5.3f,7.8f,9.3f)){
System.out.print("能够成三角形,周长为: ");
System.out.printf("%9.2f",t.getCircumference());}
else
System.out.println("不能构成三角形");
}
}
mport java.util.*;
public class HuiWen
{
public static void main(String[] args)
{
Scanner in=new Scanner(System.in);
System.out.println("please input a String:");
String st=in.nextLine();
String s=st.toLowerCase();
int i=0;
int j=s.length()-1;
boolean t=true;
char first=s.charAt(i);
char last=s.charAt(j);
for(;ij;)
{
while(!(first='a'first='z'))
{
i++;
first=s.charAt(i);
}
while(!(last='a'last='z'))
{
j--;
last=s.charAt(i);
}
if(i=j)
break;
if(first==last)
{
i++;
j--;
first=s.charAt(i);
last=s.charAt(j);
}
else
{
t=false;
break;
}
}
if(t)
System.out.println(st+"是回文串");
else
System.out.println(st+"不是回文串");
}
}
//判断是否为回文字串
//什么实用的程序,说具体点!你要计算器的程序吗?
//下面是计算器的程序,把分拿来吧!
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Calculator
{
public static void main(String[] args)
{
CalculatorFrame frame=new CalculatorFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
class CalculatorFrame extends JFrame
{
public CalculatorFrame()
{
setTitle("Calculator");
CalculatorPanel panel=new CalculatorPanel();
add(panel);
pack();
}
}
class CalculatorPanel extends Panel
{
public CalculatorPanel()
{
setLayout(new BorderLayout());
result=0;
lastCommand="=";
start=true;
flag=true;
display=new JButton("0");
display.setEnabled(false);
add(display,BorderLayout.NORTH);
ActionListener insert=new InsertAction();
ActionListener command=new CommandAction();
panel=new JPanel();
panel.setLayout(new GridLayout(4,5));
addButton("7",insert);
addButton("8",insert);
addButton("9",insert);
addButton("/",command);
addButton("CE",command);
addButton("4",insert);
addButton("5",insert);
addButton("6",insert);
addButton("*",command);
addButton("Backspace",command);
addButton("1",insert);
addButton("2",insert);
addButton("3",insert);
addButton("-",command);
addButton("sqrt",command);
addButton("0",insert);
addButton(".",insert);
addButton("=",command);
addButton("+",command);
addButton("1/x",command);
add(panel,BorderLayout.CENTER);
}
private void addButton(String label,ActionListener listener)
{
JButton button=new JButton(label);
button.addActionListener(listener);
panel.add(button);
}
private class InsertAction implements ActionListener
{
public void actionPerformed(ActionEvent event)
{
String input=event.getActionCommand();
if(startflag)
{
display.setText("");
start=false;
}
if(flag)
display.setText(display.getText()+input);
}
}
private class CommandAction implements ActionListener
{
public void actionPerformed(ActionEvent event)
{
String command=event.getActionCommand();
if(command.equals("CE"))
{
display.setText("0");
start=true;
flag=true;
command="=";
}
else
if(startflag)
{
if(command.equals("-"))
{
display.setText(command);
start=false;
}
else
if((command.equals("1/x")||command.equals("sqrt"))flag)
calculate(Double.parseDouble(display.getText()),command);
else
if(flag)
lastCommand=command;
}
else
{
if(command.equals("Backspace")flag)
{
String s=display.getText();
char[] s1=s.toCharArray();
if(s.length()=2)
{
String s2=new String(s1,0,s.length()-1);
display.setText(s2);
}
else
{
display.setText("0");
start=true;
}
}
else if(flag)
{
calculate(Double.parseDouble(display.getText()),command);
lastCommand=command;
start=true;
}
}
}
}
public void calculate(double x,String command)
{
if(lastCommand.equals("+")) result+=x;
else if(lastCommand.equals("-")) result-=x;
else if(lastCommand.equals("/"))
{
if(x!=0)
result/=x;
else
{
display.setText("除数不能为0");
start=false;
flag=false;
return;
}
}
else if(lastCommand.equals("*")) result*=x;
else if(command.equals("1/x"))
{
if(x!=0)
result=1/x;
else
{
display.setText("除数不能为0");
start=false;
flag=false;
return;
}
}
else if(command.equals("sqrt"))
{
if(x=0)
result=Math.sqrt(x);
else
{
display.setText("函数输入无效");
start=false;
flag=false;
return;
}
}
else if(lastCommand.equals("=")) result=x;
display.setText(""+result);
}
private JButton display;
private JPanel panel;
private double result;
private String lastCommand;
private boolean start;
private boolean flag;
}