JAVA 编程思想第一章习题
//: ch1.01/IntChar.java
package 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.java public 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.java
package 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);
}
}/* output
data.x = 47
data.d = 1.1
data.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 = 9
sy.i = 9
sz.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;
/**
* <pre>
* System.out.println(new date());
* </pre>
* <pre> 格式化输出 </pre>
*/
public class Html {
/** A variable comment */
public int i;
/** A method comment
* you can <em>even</em>insert a list
* <ol>
* <li> Item one
* <li> Item two
* <li> Item three
* </ol>
* <ol>
* <li>有序 HTML 列表:
* </ol>
*/
public void f()
{ } }///~
ch1.15
//: ch1.2/HelloWorld.java
/************here can't show***********
*/
package Object;
import java.util.*;
/**
* @author feilong
*<code>d</code>
*/
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.java
package 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 tall
Tree is 0 feet tall
overloaded method: Tree is 0 feet tall
creating new Tree that is 1 feet tall
Tree is 1 feet tall
overloading method: Tree is 1 feet tall
overloading method: Tree is 2 feet tall
Tree is 2f feet tall
overloading method: Tree is 1 feet tall
Creating new Tree that is 3 feet tall
Tree is 4 feet tall
overloading method: Tree is 4 feet tall
planting seedling
*///~
JAVA 编程思想第一章习题的更多相关文章
- [Java编程思想] 第一章 对象导论
第一章 对象导论 "我们之所以将自然界分解,组织成各种概念,并按其含义分类,主要是因为我们是整个口语交流社会共同遵守的协定的参与者,这个协定以语言的形式固定下来--除非赞成这个协定中规定的有 ...
- 学习java编程思想 第一章 对象导论
一.面向对象的五个基本特性: 1.万物皆为对象.将对象视为奇特的变量,他可以存储数据,还可以要求它在自身上执行操作. 2.程序是对象的合集,他们通过发送消息告诉彼此所要做的. 3.每个对象都有自己的由 ...
- JAVA编程思想第一章——对象导论
- java编程思想第九章接口
9.1抽象类和抽象方法 为什么要有抽象类? 是希望通过通用接口操作一系列类. 那么抽象类的形式是什么样的呢? 声明类的使用使用abstract关键字,且在该类中应该具有抽象方法. 注:抽象方法被关键字 ...
- Java编程思想 第九章 接口
第九章 接口 抽象类和抽象方法 抽象:从具体事物抽出.概括出它们共同的方面.本质属性与关系等,而将个别的.非本质的方面.属性与关系舍弃,这种思维过程,称为抽象. 这句话概括了抽象的概念,而在Java中 ...
- [Java编程思想] 第二章 一切都是对象
第二章 一切都是对象 2.1 用引用操纵对象 创建一个String引用: String s; 这里所创建的只是引用,并不是对象. 创建一个引用的同时便初始化: String s = &qu ...
- JAVA编程思想第一题出现错误
//: object/E01_DefaultInitialization.java public class E01_DefaultInitialization{ int i ; char c ; p ...
- JAVA编程思想第二章答案
欢迎访问我的CSDN博客查看https://mp.csdn.net/mdeditor/94797839# 有其他问题欢迎发送邮箱至hpzhangjunjiell@163.com 感谢
- 《java编程思想》读书笔记(一)开篇&第五章(1)
2017 ---新篇章 今天终于找到阅读<java编程思想>这本书方法了,表示打开了一个新世界. 第一章:对象导论 内容不多但也有20页,主要是对整本书的一个概括.因为已经有过完整JAV ...
随机推荐
- java使用Iterator 迭代器
在springboot中,findall返回的类型为Iterable, Iterator 常用方法: hasnext() next(); Iterable<User> iterable = ...
- Flask与mysql数据库字段类型的区别以及基本用法
Mysql里面的int在Flask中里面使用Integer Mysql里面的varcahar在Flask中里面使用String 与Mysql数据库需要导入模块 #导入第三方链接库sql点金术 from ...
- 2017-2018-2 20165231 实验三 敏捷开发与XP实践
实验报告封面 课程:Java程序设计 班级:1652班 姓名:王杨鸿永 学号:20165231 指导教师:娄嘉鹏 实验日期:2018年4月28日 实验时间:15:25 - 17:15 实验序号:实验三 ...
- 【转】Python之面向对象与类
[转]Python之面向对象与类 本节内容 面向对象的概念 类的封装 类的继承 类的多态 静态方法.类方法 和 属性方法 类的特殊成员方法 继承层级关系中子类的实例对象对属性的查找顺序问题 一.面向对 ...
- Linux查看本机IP:curl cip.cc
curl http://members.3322.org/dyndns/getip curl ip.6655.com/ip.aspx curl ifconfig.me curl icanhazip.c ...
- vue之递归组件实现树形目录
递归组件的应用===>可以通过组件命名来自己使用自己的组件 实例如下 父组件 <div class="content"> <detail-list :lis ...
- H5混合开发app常用代码
1.Android与H5互调可以让我们的实现混合开发,至于混合开发就是在一个App中内嵌一个轻量级的浏览器(高性能webkit内核浏览器),一部分原生的功能改为Html 5来开发.然后这个浏览器又封装 ...
- 待解决输入istream_iterator
山寨版 istream_iterator 输入 第一行是整数t,表示有t组数据,每组数据一行,三个整数加两个字符串.字符串是不含空格的. 输出 对每组数据,输出二行,在第一行输出第一个数,第二行原样输 ...
- 题解-bzoj3901 棋盘游戏
2019年第一篇文章 (。・∀・)ノ゙ Problem bzoj无良权限题,拿学长的号交的 题目概要:给定一个\(n\times n\)的矩阵.令\(x=\frac {n+1}2\).可以进行任意次以 ...
- Vue 介绍,优点,实例
一 认识vue 1.什么是vue 以数据驱动的web渐进式框架 三大主流框架: Angular React Vue 设计模式:MVVM 2.vue优点 - 以数据驱动,不直接操作DOM,效率高- 单页 ...