看板java
标 题Re: [问题] 检查保留字的程式
发信站无名小站 (Wed Apr 5 15:16:47 2006)
转信站ptt!ctu-reader!Spring!news.nctu!news.ntu!news.ee.ttu!netnews.csie.nctu
这是什麽鬼, 为什麽有二个同样名字的class
这不是java啊...
※ 引述《[email protected] (hao)》之铭言:
> 因为不知道指令是哪一个,所以我就用一个类别来做为检查的方式
> import javax.swing.JOptionPane;
> public class test{
> public static void main(String[] args){
> String box =JOptionPane.showInputDialog("请输入字串");//box装初始字串
> String box1;//box1装检察字串
> text t1 =new text();
> int num;
> num = box.indexOf(' ');//检查空白
> int num1 =0 ;
> if(num != -1){
> while( num != -1){
> box1=box.substring(num1,num);
> t1.text(box1);
> num1=num + 1 ;
> num = box.indexOf(num1,' ');
> }
> }
> else{
> t1.text(box);
> }
> }
> }
> class text(){
> String[] array = {"abstract","do","implements","protected","throws",
> "boolean","double","import","public","transient","break","else","instanceof",
> "return","true","byte","extends","int","short","try","case","false","interface",
> "static","void","catch","final","long","strictfp","volatile","char","finally",
> "native","super","while","class","float","new","switch","const","for","null",
> "synchronized","continue","goto","package","this"};
> public static text(String x){
> int j = 0;
> while(j <= 53){
> if(x.equals(array[j])
> System.out.println("字串"+ x + "为保留字");
> else
> j++;
> }
> System.out.print("没有保留字");
> }
> }
> 却出现错误讯息
> t1.text(box1); symbol:method text(java.lang.String) location:class text
> 所以很好奇是哪边的语法写错了…
--
夫兵者不祥之器物或恶之故有道者不处君子居则贵左用兵则贵右兵者不祥之器非君子
之器不得已而用之恬淡为上胜而不美而美之者是乐杀人夫乐杀人者则不可得志於天下
矣吉事尚左凶事尚右偏将军居左上将军居右言以丧礼处之杀人之众以哀悲泣之战胜以
丧礼处之道常无名朴虽小天下莫能臣侯王若能守之万物将自宾天地相合以降甘露民莫
之令而自均始制有名名亦既有夫亦将知止知止可以 pc210-59-94-148.nutn.edu.tw海