java编写app源代码 开发app代码是怎么写的
java怎么把源码变成软件,和手机APP啊
最方便的还是使用Eclipse加上Eclipseme插件编写代码,然后直接生成jar文件,使用这个文件放在手机里安装后就可以运行了。
成都创新互联主要从事成都做网站、成都网站设计、网页设计、企业做网站、公司建网站等业务。立足成都服务从江,十载网站建设经验,价格优惠、服务专业,欢迎来电咨询建站服务:028-86922220
求编写一个超级简单的Java的程序源代码
class Stack_Float
{
float nums[];
int top;
Stack_Float()
{
nums = new float[50];
top = -1;
}
boolean IsEmpty()
{
if(top == -1)
return true;
else
return false;
}
float Pop_Stack()
{
if(top==-1)
{
return 0;
}
top--;
return nums[top + 1];
}
float GetTop()
{
return nums[top];
}
void Push_Stack(float num)
{
if(top == 49)
return;
top++;
nums[top] = num;
}
}
/*****************************************************************************/
class Stack_Char
{
char str[];
int top;
Stack_Char()
{
str = new char[50];
top = -1;
}
boolean IsEmpty()
{
if(top==-1)
return true;
else
return false;
}
void Push_Stack(char ch)
{
if(top == 49)
return;
top++;
str[top] = ch;
}
char Pop_Stack()
{
if(top == -1)
return '\0';
top--;
return str[top + 1];
}
char GetTop()
{
if(top == -1)
{
System.out.print("error");
System.exit(0);
}
return str[top];
}
}
/*****************************************************************************/
public class jisuanqi extends javax.swing.JFrame
{
String show = "";
public jisuanqi()
{
initComponents();
}
char[] TranSmit(char str[])
{
char houzhui[] = new char[50]; //存放后缀表达式的字符串
int i = 0,j = 0;
char c = str[i];
Stack_Char s = new Stack_Char(); //存放运算符的栈
while(c != '=') //对算术表达式扫描未结束时
{
if(c = '0' c = '9')
{
while(c = '0' c = '9')//数字直接入栈
{
houzhui[j]=c;
j++;
i++;
c=str[i];
}
houzhui[j]='#';//用#隔开数字
j++;
}
switch(c) //扫描到运算符时
{
case '+':
case '-':
case '*':
case '/':
if(s.IsEmpty() == true) //栈空,直接入栈
{
s.Push_Stack(c);
i++;
c=str[i];
break;
}
if(ComPare(s.GetTop(),c) == -1)
{
s.Push_Stack(c); //入栈
i++;
c=str[i];
break;
}
if(ComPare(s.GetTop(),c) == 1)
{
houzhui[j]=s.Pop_Stack();//出栈元素存入后缀表达式
j++;
break;
}
}
}
while(s.IsEmpty() != true)//把剩余的运算符直接出栈
{
houzhui[j]=s.Pop_Stack();
j++;
}
houzhui[j] = '=';//后缀表达式后面加 =
j++;
houzhui[j] = '\0';
j++;
return houzhui;
}
float Count(char str[])
{
Stack_Float s = new Stack_Float();//定义存放数字的栈
char c = str[0];
int i = 0,j = 0;
float result = 0,temp,left,right;
while(c != '=') //未扫描到 = 时
{
if(c = '0' c = '9')//扫描到数字
{
temp = 0;
while(c != '#')//未读到分隔符时
{
temp = temp * 10 + c - '0';
i++;
c = str[i];
}
s.Push_Stack(temp);//进栈
}
switch(c)//扫描到运算符时
{
case '+':
{
result = s.Pop_Stack() + s.Pop_Stack();//2个数字出栈相加
s.Push_Stack(result);//最后得数进栈
break;
}
case '-':
{
right = s.Pop_Stack();//右操作数出栈
left = s.Pop_Stack();//左操作数出栈
result = left - right;
s.Push_Stack(result);
break;
}
case '*':
{
result = s.Pop_Stack() * s.Pop_Stack();//2个数字出栈相乘
s.Push_Stack(result);
break;
}
case '/':
{
right = s.Pop_Stack();//右操作数出栈
left = s.Pop_Stack();//左操作数出栈
result = left / right;
s.Push_Stack(result);
break;
}
}
i++;
c = str[i];
}
return result;
}
int ComPare(char a,char b) //判断运算符的优先级函数
{
int s[][] =
{// 栈顶元素高于算术表达式中的元素时, 返回 1,否则返回 -1
{1,1,-1,-1},
{1,1,-1,-1},
{1,1,1,1},
{1,1,1,1},
};
char x1[]={'+','-','*','/'};//栈顶元素
char x2[]={'+','-','*','/'};//算术表达式中的元素
int k=0,m,n = 0;
for(m=0;m4;m++) //查找2个进行比较的运算符在表中的位置,并返回比较结果
{
for(n=0;n4;n++)
{
if(x1[m]==ax2[n]==b)
{
k=1;break; //找到比较结果后,跳出循环
}
}
if(k==1)
break;
}
return s[m][n];//返回比较结果
}
/*****************************************************************************/
@SuppressWarnings("unchecked")
// editor-fold defaultstate="collapsed" desc="Generated Code"//GEN-BEGIN:initComponents
private void initComponents() {
text = new javax.swing.JTextField();
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jButton3 = new javax.swing.JButton();
jButton4 = new javax.swing.JButton();
jButton5 = new javax.swing.JButton();
jButton6 = new javax.swing.JButton();
jButton7 = new javax.swing.JButton();
jButton8 = new javax.swing.JButton();
jButton9 = new javax.swing.JButton();
jButton10 = new javax.swing.JButton();
jButton11 = new javax.swing.JButton();
jButton12 = new javax.swing.JButton();
jButton13 = new javax.swing.JButton();
jButton14 = new javax.swing.JButton();
jButton21 = new javax.swing.JButton();
jButton22 = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
getContentPane().setLayout(null);
getContentPane().add(text);
text.setBounds(10, 10, 270, 30);
jButton1.setText("1");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
getContentPane().add(jButton1);
jButton1.setBounds(10, 50, 60, 25);
jButton2.setText("2");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
getContentPane().add(jButton2);
jButton2.setBounds(80, 50, 60, 25);
jButton3.setText("3");
jButton3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton3ActionPerformed(evt);
}
});
getContentPane().add(jButton3);
jButton3.setBounds(150, 50, 60, 25);
jButton4.setText("4");
jButton4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton4ActionPerformed(evt);
}
});
getContentPane().add(jButton4);
jButton4.setBounds(220, 50, 60, 25);
jButton5.setText("5");
jButton5.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton5ActionPerformed(evt);
}
});
getContentPane().add(jButton5);
jButton5.setBounds(10, 80, 60, 25);
jButton6.setText("6");
jButton6.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton6ActionPerformed(evt);
}
});
getContentPane().add(jButton6);
jButton6.setBounds(80, 80, 60, 25);
jButton7.setText("7");
jButton7.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton7ActionPerformed(evt);
}
});
getContentPane().add(jButton7);
jButton7.setBounds(150, 80, 60, 25);
jButton8.setText("8");
jButton8.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton8ActionPerformed(evt);
}
});
getContentPane().add(jButton8);
jButton8.setBounds(220, 80, 60, 25);
jButton9.setText("9");
jButton9.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton9ActionPerformed(evt);
}
});
getContentPane().add(jButton9);
jButton9.setBounds(10, 110, 60, 25);
jButton10.setText("0");
jButton10.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton10ActionPerformed(evt);
}
});
getContentPane().add(jButton10);
jButton10.setBounds(80, 110, 60, 25);
jButton11.setText("+");
jButton11.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton11ActionPerformed(evt);
}
});
getContentPane().add(jButton11);
jButton11.setBounds(150, 110, 60, 25);
jButton12.setText("-");
jButton12.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton12ActionPerformed(evt);
}
});
getContentPane().add(jButton12);
jButton12.setBounds(220, 110, 60, 25);
jButton13.setText("*");
jButton13.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton13ActionPerformed(evt);
}
});
getContentPane().add(jButton13);
jButton13.setBounds(10, 140, 60, 25);
jButton14.setText("/");
jButton14.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton14ActionPerformed(evt);
}
});
getContentPane().add(jButton14);
jButton14.setBounds(80, 140, 60, 25);
jButton21.setText("CE");
jButton21.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton21ActionPerformed(evt);
}
});
getContentPane().add(jButton21);
jButton21.setBounds(150, 140, 60, 25);
jButton22.setText("=");
jButton22.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton22ActionPerformed(evt);
}
});
getContentPane().add(jButton22);
jButton22.setBounds(220, 140, 60, 25);
pack();
}// /editor-fold//GEN-END:initComponents
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
show += "1";
text.setText(show);
}//GEN-LAST:event_jButton1ActionPerformed
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
show += "2";
text.setText(show);
}//GEN-LAST:event_jButton2ActionPerformed
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
show += "3";
text.setText(show);
}//GEN-LAST:event_jButton3ActionPerformed
private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
show += "4";
text.setText(show);
}//GEN-LAST:event_jButton4ActionPerformed
private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed
show += "5";
text.setText(show);
}//GEN-LAST:event_jButton5ActionPerformed
private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton6ActionPerformed
show += "6";
text.setText(show);
}//GEN-LAST:event_jButton6ActionPerformed
private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton7ActionPerformed
show += "7";
text.setText(show);
}//GEN-LAST:event_jButton7ActionPerformed
private void jButton8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton8ActionPerformed
show += "8";
text.setText(show);
}//GEN-LAST:event_jButton8ActionPerformed
private void jButton9ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton9ActionPerformed
show += "9";
text.setText(show);
}//GEN-LAST:event_jButton9ActionPerformed
private void jButton10ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton10ActionPerformed
show += "0";
text.setText(show);
}//GEN-LAST:event_jButton10ActionPerformed
private void jButton13ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton13ActionPerformed
show += "*";
text.setText(show);
}//GEN-LAST:event_jButton13ActionPerformed
private void jButton14ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton14ActionPerformed
show += "/";
text.setText(show);
}//GEN-LAST:event_jButton14ActionPerformed
private void jButton21ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton21ActionPerformed
show = "";
text.setText("");
}//GEN-LAST:event_jButton21ActionPerformed
private void jButton22ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton22ActionPerformed
show += "=";
text.setText(show);
char str1[] = new char[50];
char str2[] = new char[50];
float result = 0;
str1 = show.toCharArray();
str2 = TranSmit(str1);
result = Count(str2);
text.setText("" + result);
show = "";
}//GEN-LAST:event_jButton22ActionPerformed
private void jButton12ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton12ActionPerformed
show += "-";
text.setText(show);
}//GEN-LAST:event_jButton12ActionPerformed
private void jButton11ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton11ActionPerformed
show += "+";
text.setText(show);
}//GEN-LAST:event_jButton11ActionPerformed
public static void main(String args[])
{
jisuanqi j = new jisuanqi();
j.setBounds(300, 300, 300, 195);
j.setVisible(true);
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton10;
private javax.swing.JButton jButton11;
private javax.swing.JButton jButton12;
private javax.swing.JButton jButton13;
private javax.swing.JButton jButton14;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton21;
private javax.swing.JButton jButton22;
private javax.swing.JButton jButton3;
private javax.swing.JButton jButton4;
private javax.swing.JButton jButton5;
private javax.swing.JButton jButton6;
private javax.swing.JButton jButton7;
private javax.swing.JButton jButton8;
private javax.swing.JButton jButton9;
private javax.swing.JTextField text;
// End of variables declaration//GEN-END:variables
}
求JAVA入门小程序源代码
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;
}
我有一套java语言app源码怎么搭建成app需要什么环境
如果说是局域网服务器维护的话,大可不必如此,因为如果你这样做相当于是一个B/S的结构;那么实际上要对手机进行区分几乎是不可能的。连接Wifi,意味着最多只能处理数据报文,而不是在那些手机上运行程序。网络数据报文中,和数据无关的部分就是网络协议部分的数据,这部分数据中,传输层、网络层数据都没有用,只有数据链路层的MAC地址可能对你有点用,因为每张网卡的MAC地址是不同的,你至多可以知道是哪家公司生产的,但是具体在什么设备上,是不可能知道的(况且那些数据理论上其实都是可以改的)
如果是针对手机编程的话,用Java代码的无非就是Android编程,这就和连接什么Wifi没有关系了。Android编程要获取手机信息的方法我也不清楚,你去谷歌的API里面看看,或者去搜搜看吧,应该不少。
怎样把一个java源代码做成一个软件成品?
其实就是用一个外部程序 调用java虚拟机运行你的java程序。
可以做一个批处理文件,在里面调用java 虚拟机运行你的java程序。
也可以用某种编程语言,像vb ,c 或c++编个程序,生成exe,能调用java虚拟机运行你的程序,很简单的。
【源代码】
源代码(也称源程序),是指一系列人类可读的计算机语言指令。 在现代程序语言中,源代码可以是以书籍或者磁带的形式出现,但最为常用的格式是文本文件,这种典型格式的目的是为了编译出计算机程序。
分享题目:java编写app源代码 开发app代码是怎么写的
文章来源:http://pwwzsj.com/article/docjddh.html