java城市代码 城市代码怎么来的
java 代码
那是ASCII..
创新互联公司专注于魏都企业网站建设,成都响应式网站建设公司,商城建设。魏都网站建设公司,为魏都等地区提供建站服务。全流程按需规划网站,专业设计,全程项目跟踪,创新互联公司专业和态度为您提供的服务
package mkpoli.test;
public class UpperCase {
public static void main(String[] args) {
String a = "asdas";
char[] b = new char[a.length()];
for (int i = 0; i a.length(); i++) {
b[i] = (char) toUpperCase((int) a.charAt(i));
}
System.out.println(new String(b));
}
static int toUpperCase(int ch) {
return (ch ^ ' ');
}
}
Java程序代码
import java.awt.*;//计算器实例
import java.awt.event.*;
public class calculator
{
public static void main(String args[])
{
MyWindow my=new MyWindow("计算器");
}
}
class MyWindow extends Frame implements ActionListener
{ StringBuffer m=new StringBuffer();
int p;
TextField tex;
Button b0,b1,b2,b3,b4,b5,b6,b7,b8,b9,jia,jian,cheng,chu,deng,dian,qingling,kaifang;
MyWindow(String s)
{
super(s);
//StringBuffer s2=new StringBuffer();
//String s;
tex=new TextField(18);
b0=new Button(" 0 ");
b1=new Button(" 1 ");
b2=new Button(" 2 ");
b3=new Button(" 3 ");
b4=new Button(" 4 ");
b5=new Button(" 5 ");
b6=new Button(" 6 ");
b7=new Button(" 7 ");
b8=new Button(" 8 ");
b9=new Button(" 9 ");
dian=new Button(" . ");
jia=new Button(" + ");
jian=new Button(" - ");
cheng=new Button(" × ");
chu=new Button(" / ");
deng=new Button(" = ");
qingling=new Button(" 清零 ");
kaifang=new Button(" √ ");
setLayout(new FlowLayout());
add(tex);
add(b0);
add(b1);
add(b2);
add(b3);
add(b4);
add(b5);
add(b6);
add(b7);
add(b8);
add(b9);
add(dian);
add(jia);
add(jian);
add(cheng);
add(chu);
add(kaifang);
add(qingling);
add(deng);
b0.addActionListener(this);
b1.addActionListener(this);
b2.addActionListener(this);
b3.addActionListener(this);
b4.addActionListener(this);
b5.addActionListener(this);
b6.addActionListener(this);
b7.addActionListener(this);
b8.addActionListener(this);
b9.addActionListener(this);
jia.addActionListener(this);
jian.addActionListener(this);
cheng.addActionListener(this);
chu.addActionListener(this);
dian.addActionListener(this);
deng.addActionListener(this);
qingling.addActionListener(this);
kaifang.addActionListener(this);
setBounds(200,200,160,280);
setResizable(false);//不可改变大小
setVisible(true);
validate();
addWindowListener(new WindowAdapter()
{ public void windowClosing(WindowEvent ee)
{ System.exit(0);
}
});
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==b0)
{
m=m.append("0");
tex.setText(String.valueOf(m));
}
if(e.getSource()==b1)
{
m=m.append("1"); tex.setText(String.valueOf(m));
}
if(e.getSource()==b2)
{
m=m.append("2"); tex.setText(String.valueOf(m));
}
if(e.getSource()==b3)
{
m=m.append("3"); tex.setText(String.valueOf(m));
}
if(e.getSource()==b4)
{
m=m.append("4"); tex.setText(String.valueOf(m));
}
if(e.getSource()==b5)
{
m=m.append("5"); tex.setText(String.valueOf(m));
}
if(e.getSource()==b6)
{
m=m.append("6"); tex.setText(String.valueOf(m));
}
if(e.getSource()==b7)
{
m=m.append("7"); tex.setText(String.valueOf(m));
}
if(e.getSource()==b8)
{
m=m.append("8"); tex.setText(String.valueOf(m));
}
if(e.getSource()==b9)
{
m=m.append("9"); tex.setText(String.valueOf(m));
}
if(e.getSource()==jia)
{
m=m.append("+"); tex.setText(String.valueOf(m));
}
if(e.getSource()==jian)
{
m=m.append("-"); tex.setText(String.valueOf(m));
}
if(e.getSource()==cheng)
{
m=m.append("*"); tex.setText(String.valueOf(m));
}
if(e.getSource()==chu)
{
m=m.append("/"); tex.setText(String.valueOf(m));
}
if(e.getSource()==dian)
{
m=m.append("."); tex.setText(String.valueOf(m));
}
String mm=String.valueOf(m);
int p1=mm.indexOf("+");
int p2=mm.indexOf("-");
int p3=mm.indexOf("*");
int p4=mm.indexOf("/");
if(p1!=-1)
{
p=p1;
}
else if(p3!=-1)
{
p=p3;
}
else if(p2!=-1)
{
p=p2;
}
else if(p4!=-1)
{
p=p4;
}
if(e.getSource()==deng)
{
String m1=mm.substring(0,p);
String m2=mm.substring(p+1);
String ch=mm.substring(p,p+1);
//System.out.println(m1);
//System.out.println(m2);
//System.out.println(ch);
if(ch.equals("+"))
{
float n1=Float.parseFloat(m1);
float n2=Float.parseFloat(m2);
float sum=n1+n2;
String su=String.valueOf(sum);
tex.setText(su);
}
if(ch.equals("-"))
{
float n1=Float.parseFloat(m1);
float n2=Float.parseFloat(m2);
float sum=n1-n2;
String su=String.valueOf(sum);
tex.setText(su);
}
if(ch.equals("*"))
{
float n1=Float.parseFloat(m1);
float n2=Float.parseFloat(m2);
float sum=n1*n2;
String su=String.valueOf(sum);
tex.setText(su);
}
if(ch.equals("/"))
{
float n1=Float.parseFloat(m1);
float n2=Float.parseFloat(m2);
float sum=n1/n2;
String su=String.valueOf(sum);
tex.setText(su);
}
}
if(e.getSource()==qingling)
{StringBuffer kk=new StringBuffer();
m=kk;
tex.setText("0");
// System.out.println(mm);
}
if(e.getSource()==kaifang)
{
String t=tex.getText();
float num=Float.parseFloat(t);
double nub=Math.sqrt(num);
tex.setText(String.valueOf(nub));
}
}
}
java简单的代码
原来File fDir=new File("D://");是这样的File fDir=new File(File.separator); 我改了 但是还是不行 啊。回答: import java.io.File; public class NewClass7 { public static void main(String[] args) throws Exception{ File fDir=new File("F://");//分隔符 separator String strFile="sg"+File.separator+"DT"+File.separator+"1.txt"; File f=new File(fDir,strFile); f.createNewFile();}}当然,如果按照你这段代码,你要确保目标盘上得有sg/DT这两个目录,否则你就要在代码里创建这两个目录了。补充: 看我修改后的代码,必须引用java.io.File类,你原来代码中没有,还有,你要确保目标盘上得有sg/DT这两个目录。追问: 我多问一句。这段代码 属于J2EE 吧?回答: 不能这样说,J2EE是JAVA体系的一部份,是一种JAVA应用开发的技术架构。你这段代码只是一段JAVA的基础代码。
java 代码
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
public class Emp {
private String id;
private int age;
private String sex;
public Emp(String id, int age, String sex) {
this.id = id;
this.age = age;
this.sex = sex;
}
public int getAge() {
return age;
}
public String getId() {
return id;
}
public String getSex() {
return sex;
}
public static void main(String[] arg)
{
HashMapInteger,Emp map = new HashMapInteger,Emp();
map.put(1, new Emp("E00001",23,"male"));
map.put(2, new Emp("E00002",23,"female"));
map.put(3, new Emp("E00003",3,"male"));
map.put(4, new Emp("E00004",2,"male"));
map.put(5, new Emp("E00005",152,"female"));
map.put(6, new Emp("E00006",223,"male"));
map.put(7, new Emp("E00007",723,"female"));
map.put(8, new Emp("E00008",223,"male"));
map.put(9, new Emp("E00009",223,"male"));
map.put(10, new Emp("E00010",23,"female"));
while(true)
{
System.out.print("input u want num:");
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
Boolean b = false;
Integer outPutNum = null;
do
{
try {
b = false;
String input = br.readLine();
outPutNum = new Integer(input);
} catch (IOException e) {
e.printStackTrace();
} catch(Exception e)
{
System.out.println("input a num!");
System.out.print("input u want num again:");
b = true;
}
}
while(b);
for(int i = 0; i != outPutNum; i++)
{
Emp e = map.get(i + 1);
if(e == null)
{
System.out.println("not so much emp");
break;
}
else
{
System.out.println(e.getId() + "\t" + e.getAge() + "\t" + e.getSex());
}
}
}
}
}
//调试成功,需要注释,HI
当前文章:java城市代码 城市代码怎么来的
链接分享:http://ybzwz.com/article/hhcsio.html