例如C#程序:
static void Main(string [] args)
{
string []friendName={"joey","tom","robert"};
int i;
for(i=0;i<friendName.length;i++)
{
Console.WriteLine(friendName[i]);
}
Console.ReadKey();
}
其中console.ReadKey()的功能是等待键盘输入才退出程序。为了使调试时看到输出结果。
如果没有此句,命令窗口会一闪而过。
那么换作在JAVA中该怎么实现呢???
static void Main(string [] args)
{
string []friendName={"joey","tom","robert"};
int i;
for(i=0;i<friendName.length;i++)
{
Console.WriteLine(friendName[i]);
}
Console.ReadKey();
}
其中console.ReadKey()的功能是等待键盘输入才退出程序。为了使调试时看到输出结果。
如果没有此句,命令窗口会一闪而过。
那么换作在JAVA中该怎么实现呢???
注意得按回车键,另外还需要处理IOException。
完整示例:public static void main(String[]args) throws IOException
{
//之前的操作
System.out.println( "按回车键退出..." );
System.in.read();
}
double d = scanner.nextDouble();//可以返回你要的基本类型数据
java ?