下载此文档

java题库.ppt


文档分类:IT计算机 | 页数:约23页 举报非法文档有奖
1/23
下载提示
  • 1.该资料是网友上传的,本站提供全文预览,预览什么样,下载就什么样。
  • 2.下载该文档所得收入归上传者、原创者。
  • 3.下载的文档,不会出现我们的网址水印。
1/23 下载此文档
文档列表 文档介绍
习题: 说明程序的运行结果或实现功能
1. class StringTest1 {
public static void main(String[] args)
{
String s1="hello";
String s2=new String("hello");
if((s2)){
("相等");
}else{
("不相等");
}
}
}
2
public class Sum
{ public static void main( String args[ ])
{ double sum = ;
for ( int i = 1 ; i <= 100 ; i + + )
sum += /(double) i ;
( "sum="+sum );
}
}
3. public class TestArray
{
public static void main(String args[ ]){
int i , j ;
int a[ ] = { 5,9,6,8,7};
for ( i = 0 ; i < -1; i ++ ) {
int k = i;
for ( j = i ; j < ; j++ )
if ( a[j]<a[k] ) k = j;
int temp =a[i];
a[i] = a[k];
a[k] = temp;
}
for ( i =0 ; i<; i++ )
(a[i]+" ");
( );
}
}
4. import .*;
public class TestFile
{
public static void main(String args[]) throws Exception
{
BufferedReader br=new BufferedReader(new InputStreamReader());
BufferedWriter bw = new BufferedWriter(new FileWriter(“"));
String s;
while (true)
{
("请输入一个字符串: ");
();
s=();
if (()==0) break;
(s);
();
}
();
}
}
5. class Exp1
{
public static void main(String[] args)
{
String s,s1="";
char c;
s=args[0];
for (int i=0;i<();i++)
{
c=(i);
if(c>='a' && c<='z'){
s1=s1+(c);
}else{
s1=s1+(c);
}
}
(s1);
}
}
若在dos命令行输入:java Exp1 abcDEF,则输出为。
6. import .*;
public class VecApp {
public static void main(String[] args) {
Vector v = new Vector();
for(int i = 0; i <2; i++)
("v"+i);
(new Integer(1),0);
Enumeration e = ();
while(())
(()+" ");
();
("v1" );
for(int i = 0; i < () ; i++)
((i) +" ");
();
}
}
7. class Int

java题库 来自淘豆网m.daumloan.com转载请标明出处.

相关文档 更多>>
非法内容举报中心
文档信息
  • 页数23
  • 收藏数0 收藏
  • 顶次数0
  • 上传人xunlai783
  • 文件大小74 KB
  • 时间2018-06-15
最近更新