简单程序有几个不明白的地方求答案。。。。
public class BJ
{
public static void main(String args[]) throws Exception
{
if(args[0].length()<10)
System.out.print("Enter a string:include 10 chars");
else
{
String str=new String("bacdbcabca");
int n=0;
System.out.print("The Standard answer:");
for(int x=0;x<str.length();x++)
System.out.print(" "+str.charAt(x));
System.out.println();
System.out.print("The Student answer:");
for(int x=0;x<str.length();x++)
{
if(args[0].charAt(x)==str.charAt(x))
{
n++;
System.out.print(" "+args[0].charAt(x));
}
else
System.out.print(" "+"@");
}
System.out.println( );
System.out.println("The correct answers:"+n);
}
}
}
问题1:if(args[0].length()<10)这句话里是判断输入的字符是否小于10个的意思那为什么args[]里要有0?str.length是这个数组元素的总长度那args[0].length是什么意思?
问题2:int n=0里的n代表什么意思?是看有多少个字符相当么?然后相等的数++??
问题3:str.charAt(x)这个是什么意思?尤其是charAt这个是实现什么功能?