博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
JAVA 编程思想第一章习题
阅读量:4705 次
发布时间:2019-06-10

本文共 6337 字,大约阅读时间需要 21 分钟。

 

//: ch1.01/IntChar.javapackage object; import java.util.*;public class IntChar {     int x; char y;      public IntChar(){         System.out.println(x);        System.out.println(y);          }     public static void main(String[] args) {         new IntChar();     } }

/* output:

test
*///~

 

 

package Object;//: ch1.2/HelloWorld.javapublic class HelloWorld {    public static void main(String[] args) {        System.out.println("Hello, World");    }}/*     * output:(55% match) hell. it's:     *  Wed Nvember 01 13:42 MDT 2018     */// :~
//: ch1.3/ATypeName.javapackage Object;import java.util.*;public class ATypeName{    int x;    public static void main(String[] args){        ATypeName a = new ATypeName();        a.x=4;        System.out.print(a.x);    }    }/* class object*/// :~
//: ch1.4/DataOnly.java/**study * @author feilong */package Object;import java.util.*;public class DataOnly{    public static void main(String[] args){        DataOnly data = new DataOnly();    }}
//: ch1.5/Dataonly.java/**study * @author feilong */package Object;import java.util.*;public class Dataonly{        int x;        double d;        boolean b;    public static void main(String[] args){        Dataonly data = new Dataonly();        data.x=47;        data.d=1.1;        data.b=false;        System.out.println("data.x="+data.x);        System.out.println("data.d="+data.d);        System.out.println("data.b="+data.b);    }}/* outputdata.x = 47data.d = 1.1data.b = false*///:~
//: ch1.6/Storage.java/**@version 1.6* @author feilong*/package Object;import java.util.*;public class Storage{    public int storage(String s){        return s.length()*2;    }    public static void main(String[] args){        Storage st = new Storage();        String s  = "helloword";        int l=st.storage(s);        System.out.println(l);    }}/* output: * storage(s); *///:~
//: ch1.7/Incrementable.java/**@author feilong*  @version 1.7*/package Object;import java.util.*;class StaticTest{    static int i = 47;}public class Incrementable{            static void increment()    {        StaticTest.i++;    }    public static void main(String[] args){        Incrementable sf = new Incrementable();        sf.increment();        System.out.println(StaticTest.i);    }}/* Output:StaticTest.i*///:~//: ch1.8/ShowStatic.java/**@author feilong*  @version 1.8*/
package object;import java.util.*;public class ShowStatic{    static int i = 7;        public static void main(String[] args){        ShowStatic ss = new ShowStatic();        ss.i=9;        ShowStatic sy = new ShowStatic();        ShowStatic sz = new ShowStatic();        System.out.println("ss.i = "+ss.i);        System.out.println("sy.i = "+sy.i);        System.out.println("sz.i = "+sz.i);    }}/* output:ss.i = 9sy.i = 9sz.i = 9*///:~ CH1.11

//: Object/AllTheColorsOfTheRaibow.java

/**@author feilong
* @version 1.0
*/
package object;
import java.util.*;

public class AllTheColorsOfTheRaibow{

int anIntegerRepreSentingColors;
void changeTheHueOfTheColor(int newHue)
{
anIntegerRepreSentingColors = newHue;
}
public static void main(String[] args)
{
AllTheColorsOfTheRaibow all = new
AllTheColorsOfTheRaibow();
all.changeTheHueOfTheColor(8);
System.out.println(all.anIntegerRepreSentingColors);
}
}/* output:
这个程序 抄了作者的
*///:~

ch1.12

// object/HelloWord.java

/**The first Thinking in java example program
* Displays a string and today's date
* @author feilong
* @author https://home.cnblogs.com/u/jiangfeilong/
* @version 2.0
*/
package object;
import java.util.*;

public class HelloWord2 {

/** Entry point to class & application
* @param args array of string arguments
* @author exceptions No exception thrown
*/
public static void main(String[] args)
{
System.out.printf("%s\n","hello world");
System.out.println(new Date());
}
}/* output:
hello it's
wed November 5 23:01:34 MDT 2018
*///~

 

 ch1.13

//: object/Documentation.java

package object;
/**
* @author feilong
* Run Documentation1.java Documentation2.java
* and Documentation3.java through javadoc. Verify
* the resulting documentation with your Web
* browser
*/
public class Documentation {
public static void main(String[] args)
{
}

}///~

 

ch1.14

//: object/Html.java  package object;/** * 
 * System.out.println(new date()); * 
*
 格式化输出 
*/public class Html { /** A variable comment */ public int i; /** A method comment * you can eveninsert a list *
    *
  1. Item one *
  2. Item two *
  3. Item three *
*
    *
  1. 有序 HTML 列表: *
*/ public void f() { }}///~

ch1.15

//: ch1.2/HelloWorld.java/************here can't show*********** */package Object;import java.util.*;/** * @author feilong  *d */public class HelloWorld {    /** @param args description(must have two **)     * efsadf     */    public static void main(String[] args) {        /* @return description         * true         */        System.out.println("Hello, World");    }     }/*     * output:(55% match) hell. it's:     *  Wed Nvember 01 13:42 MDT 2018     */// :~

ch1.16

//: object/OverLoading.javapackage object;import java.util.*;import static net.mindview.util.Print.*;class Tree{    int height;    Tree()    {        print("Planting a seeding");        height = 0;    }    Tree(int initialHeight)    {        height = initialHeight;        print("Creating new tree that is" +        height + " feet tall");    }    void info(){        print("Tree is " +  height + "feei tall");    }    void info(String s)    {        print(s+ "; Tree is " + height + " feet tall");    }    }/** * @author feilong */public class OverLoading {    /**@param args put here can use */    public static void main(String[] args)    {        for(int i =0 ;i<5; i++)        {            Tree t = new Tree(i);            t.info();            t.info("OverLoading method");        }        new Tree();            }    }/*Creating new Tree that is 0  feet tallTree is 0 feet tall overloaded method: Tree is 0 feet tallcreating new Tree that is 1 feet tallTree is 1 feet talloverloading method: Tree is 1 feet talloverloading method: Tree is 2 feet tallTree is 2f feet talloverloading method: Tree is 1 feet tallCreating new Tree that  is 3 feet tallTree is 4 feet talloverloading method: Tree is 4 feet tallplanting seedling*///~

 

转载于:https://www.cnblogs.com/jiangfeilong/p/9903787.html

你可能感兴趣的文章
RSA加密算法 C++实现
查看>>
smarty模板及其应用
查看>>
[转]C#网络编程(基本概念和操作) - Part.1
查看>>
[转]VS2010/MFC编程入门之五(MFC消息映射机制概述)
查看>>
儿童教学相关网站
查看>>
[转]win系统下nodejs安装及环境配置
查看>>
【Eclipse】开发专题
查看>>
PHP中构造函数和析构函数解析
查看>>
decimal模块
查看>>
Python函数缓存
查看>>
MongoDB 客户端 MongoVue
查看>>
《IT项目管理》读书笔记(8) —— 项目人力资源管理
查看>>
mongodb 学习笔记
查看>>
大数据仓库对业务数据的几个基本要求
查看>>
POSIX信号
查看>>
Thinkphp 中间件结合Validate
查看>>
orcale => 含义
查看>>
在 Virtual Box 安装 Mac Os 并安装 Qt 开发应用
查看>>
入门django
查看>>
PDO exec() query() prepare() PDOException 事务处理
查看>>