java容器的一习题!!初学者!

pangxie887 2009-09-14 02:57:57
初学请教~~
一java容器,Array Implementation 的习题~~~

ps:初学者,又在国外学习,不要人身攻击!!!
自己写了点~~但是还是晕晕的~~~谁有时间帮忙写看看,给偶学习一下~~

The interface that you will be implementing is a bag (or multiset) collection used for
storing a set of objects—including duplicates.
The collection will be called a “rank” bag, as it will have some additional methods
for accessing the smallest, second-smallest, and kth-smallest item stored in it. Your
implementation for part 1:
will implement the RankBag interface in the RankBagArray class;
will use an unsorted array for storing the objects; and
will not use any built-in collections to work with the objects (with the exception of
the uniqueSet() method).





附件如下~
http://www.javatx.cn/upfiles/club/20099/2009091402284953380.zip
...全文
270 23 打赏 收藏 转发到动态 举报
写回复
用AI写文章
23 条回复
切换为时间正序
请发表友善的回复…
发表回复
pangxie887 2009-09-15
  • 打赏
  • 举报
回复
还是很感谢
  • 打赏
  • 举报
回复
mark
dujun3245350 2009-09-15
  • 打赏
  • 举报
回复
接分
tfsict2008 2009-09-15
  • 打赏
  • 举报
回复
class < T extends ?>
cping1982 2009-09-15
  • 打赏
  • 举报
回复
这年头人都变懒了,我这样一直很懒的反倒显得勤快……


import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

/**
*
* Copyright 2008 - 2009
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*
* @project loonframework
* @author chenpeng
* @email:ceponline@yahoo.com.cn
* @version 0.1
*/

public class RankBagArray<E extends Comparable<E>> implements RankBag<E> {

// 初始的集合大小
private final static int INITIAL_CAPACITY = 20;

// 保存集合的对象数组
private Object[] elements;

// 集合的预期长度
private int size;

/**
* Constructor
*/
public RankBagArray() {
size = 0;
elements = new Object[INITIAL_CAPACITY];
}

/**
* 互换数据
*
* @param data
* @param x
* @param y
*/
private void swap(Object[] data, int x, int y) {
Object temp = data[x];
data[x] = data[y];
data[y] = temp;
}

/**
* 排序数据
*
* @param src
* @param dest
* @param low
* @param high
* @param off
*/
private void sort(Object[] src, Object[] dest, int low, int high, int off) {
int length = high - low;
if (length < 10) {
for (int i = low; i < high; i++)
for (int j = i; j > low
&& ((Comparable) dest[j - 1]).compareTo(dest[j]) > 0; j--) {
swap(dest, j, j - 1);
}
return;
}
int destLow = low;
int destHigh = high;
low += off;
high += off;
int mid = (low + high) >> 1;
sort(dest, src, low, mid, -off);
sort(dest, src, mid, high, -off);
if (((Comparable) src[mid - 1]).compareTo(src[mid]) <= 0) {
System.arraycopy(src, low, dest, destLow, length);
return;
}
for (int i = destLow, p = low, q = mid; i < destHigh; i++) {
if (q >= high || p < mid
&& ((Comparable) src[p]).compareTo(src[q]) <= 0) {
dest[i] = src[p++];
} else {
dest[i] = src[q++];
}
}
}

/**
* 排序数据
*
* @return
*/
private Object[] sort(Object[] o) {
if (size == 0) {
return null;
}
Object[] dest = new Object[size];
System.arraycopy(o, 0, dest, 0, size);
sort(o, dest, 0, size, 0);
int i = 0, j = 0;
for (i = 0; i < size - 1; i++) {
if (dest[i] != dest[i + 1]) {
dest[i] = dest[i + 1];
j++;
}
}
return dest;
}

/**
* 扩充数组容量
*
* @param obj
* @param index
* @return
*/
private void expandCapacity(int capacity) {
if (elements.length < capacity) {
Object[] bagArray = (Object[]) new Object[capacity];
System.arraycopy(elements, 0, bagArray, 0, size);
elements = bagArray;
}
}

/**
* 压缩数组容量
*
* @param capacity
*/
private void compressCapacity(int capacity) {
if (capacity + this.size < elements.length) {
Object[] newArray = (Object[]) new Object[this.size + 2];
System.arraycopy(elements, 0, newArray, 0, this.size);
elements = newArray;
}
}

/**
* 删除指定数据,可选择是否删除全部同类对象
*
* @param o
* @param isRemoves
* @return
*/
private boolean remove(Object o, boolean isRemoves) {
if (o == null) {
return false;
}
if (elements == null) {
return false;
}
boolean flag = false;
for (int i = size; i > 0; i--) {
if (o.equals(elements[i])) {
flag = true;
size--;
elements[i] = elements[size];
elements[size] = null;
if (size == 0) {
elements = null;
} else {
compressCapacity(2);
}
if (!isRemoves) {
return true;
}
}
}
return flag;
}

/**
* RankBag Adds an object to the bag.
*/
public boolean add(E o) {
if (size == elements.length) {
expandCapacity((size + 1) * 2);
}
return (elements[size++] = o) != null;
}

/**
* RankBag Removes all objects from the bag.
*/
public void clear() {
for (int i = 0; i < elements.length; i++) {
elements[i] = null;
}
size = 0;
}

/**
* RankBag Checks if an object exists in the bag.
*/
public boolean contains(Object o) {
if (o == null) {
return false;
}
if (elements == null) {
return false;
}
for (int i = 0; i < size; i++) {
if (elements[i] != null && o.equals(elements[i])) {
return true;
}
}
return false;
}

/**
*
* Returns the smallest (according to the natural ordering of the of the
* contained objects and the ranking system described in RankBag) in the
* bag.
*
* If more than one object qualifies as the "smallest", then any one of the
* qualifying items is returned.
*/
public E first() {
Object[] first = sort(elements);
return (E) (first == null ? null : first[0]);
}

/**
* RankBag Returns the number of instances of a specified object that have
* been added to the bag.
*/
public int getCount(Object o) {
int index = 0;
for (int i = 0; i < size; i++) {
if (o == elements[i]) {
index++;
}
}
return index;
}

/**
* RankBag Returns if the bag is empty or not.
*/
public boolean isEmpty() {
return size == 0;
}

/**
*
* Returns the kth smallest (according to the natural ordering of the
* contained objects and the ranking system described in RankBag) in the
* bag.
*
* If more than one object qualifies as the "kth smallest", then any one of
* the qualifying items is returned.
*
* In the case of k=1, this is equivalent to RankBag.first(); in the case of
* k=2, this is equivalent to RankBag.second().
*/
public E kth(int k) {
if (k < 1 || k >= size) {
return null;
}
Object[] first = sort(elements);
return (E) (first == null ? null : first[k - 1]);
}

/**
* RankBag Removes all instances of the specified object from the bag.
*/
public boolean remove(Object o) {
return remove(o, true);
}

/**
* Removes a single instance of the specified object from the bag.
*/
public boolean removeOnce(Object o) {
return remove(o, false);
}

/**
* Returns the second smallest (according to the natural ordering of the
* contained objects and the ranking system described in RankBag) in the
* bag.
*
* If more than one object qualifies as the "second smallest", then any one
* of the qualifying items may be returned.
*/
public E second() {
if (size < 2) {
return null;
}
Object[] first = sort(elements);
return (E) (first == null ? null : first[1]);
}

/**
* Returns the cardinality of the bag collection.
*/
public int size() {
return size;
}

/**
* Returns a set containing all objects in the bag without any duplicates.
* Any valid Set from the Java collections API may be returned.
*/
public Set<E> uniqueSet() {
Object[] bagArray = new Object[size];
int i = 0, j = 0;
for (i = 0; i < size - 1; i++) {
while (bagArray[i] == elements[i + 1]) {
i++;
}
bagArray[j++] = elements[i];
}
Object[] tempArray = new Object[i];
System.arraycopy(bagArray, 0, tempArray, 0, i);
return new HashSet(Arrays.asList(tempArray));
}

}
Ostroff 2009-09-14
  • 打赏
  • 举报
回复
你是用的Mac OS吧,
我好像在一本叫做
《Java动画、图形和极富客户端效果开发》
上看过类似代码
舷Kelvin 2009-09-14
  • 打赏
  • 举报
回复
能力不够就不要做这个题啊。从你能理解的开始一步一步来。谁都不是一口吃成一个胖子的。
zjx2388 2009-09-14
  • 打赏
  • 举报
回复
刚下载了,看到你那个目录就有点晕了

自己慢慢写吧,哪里有问题直接贴出来问吧


PS:你用的什么IDE
zjx2388 2009-09-14
  • 打赏
  • 举报
回复
你的集合范围小了

先看下你代码
  • 打赏
  • 举报
回复
楼主在哪国呢
roma505 2009-09-14
  • 打赏
  • 举报
回复
路过学习
yinzisheng 2009-09-14
  • 打赏
  • 举报
回复
支持下拉~~~
dixiasenlin 2009-09-14
  • 打赏
  • 举报
回复
呵呵

支持一下!
lk198186 2009-09-14
  • 打赏
  • 举报
回复
帮顶
pangxie887 2009-09-14
  • 打赏
  • 举报
回复
上面连接没有的话

http://pickup.mofile.com/9969210365180414
从这里下~~~

别砸砖呀~~
我知道要自己写才学得会~~
但是开始总得对着例子写~~~
谢谢拉~
pangxie887 2009-09-14
  • 打赏
  • 举报
回复
如果有谁有时间写的话~~
发到375298170@qq.com
谢谢
owen_008 2009-09-14
  • 打赏
  • 举报
回复
楼主在哪个国家学习啊??~呵呵,加油啊~~
loveofmylife 2009-09-14
  • 打赏
  • 举报
回复
import java.util.*;
public class MyArrayList implements List{
private Object[] data;
private int count;
public MyArrayList(){
this(10);
}
public MyArrayList(int initCap){
data=new Object[initCap];
count=0;
}
public MyArrayList(Collection c){
data=new Object[c.size()];
for(Object obj:c){
data[count++]=obj;
}
}
/**根据指定的下标插入指定的元素
* 如果下标越界则抛出IndexOutOfBoundsException异常
* @param index,element
* @return
*/
public void add(int index, Object element) {
if(count<data.length){
if(index<=count){
for(int i=index+1;i<=count;i++){
data[i+1]=data[i];
}
data[index]=element;
count++;
}else {
throw new IndexOutOfBoundsException("指定下标越界");
}
}else{
Object[] newData=new Object[2*data.length];
System.arraycopy(data, 0, newData, 0, data.length);
this.data=newData;
System.gc();
if(index<=count){
for(int i=index+1;i<=count;i++){
data[i+1]=data[i];
}
data[index]=element;
count++;
}else {
throw new IndexOutOfBoundsException("指定下标越界");
}
}

}

public boolean add(Object e) {
if(count<data.length){
data[count++]=e;
return true;
}else{
Object[] newData=new Object[2*data.length];
System.arraycopy(data, 0, newData, 0, data.length);
this.data=newData;
data[count++]=e;
return true;
}
}

public boolean addAll(Collection c) {
// TODO Auto-generated method stub
return false;
}

public boolean addAll(int index, Collection c) {
// TODO Auto-generated method stub
return false;
}

public void clear() {
data=new Object[10];
count=0;
System.gc();
}

public boolean contains(Object o) {
for(Object obj:data){
if(obj==o){
return true;
}
}
return false;
}

public boolean containsAll(Collection c) {
// TODO Auto-generated method stub
return false;
}

public Object get(int index) {
if(index<count){
Object o=new Object();
o=data[index];
return o;
}else {
throw new IndexOutOfBoundsException("指定下标越界");
}

}

public int indexOf(Object o) {
int i=0;
if(this.contains(o)){
for(Object obj:data){
if(obj==o){
return i;
}
i++;
}
}
return -1;
}

public boolean isEmpty() {
if(count==0){
return true;
}
return false;
}

public Iterator<Object> iterator() {
Iterator<Object> it=new Iterator<Object>(){
public int init=0;
public boolean hasNext() {
if(init<count){
init++;
return true;
}
return false;
}

public Object next() {
if(init<=count){
return data[init-1];
}else {
throw new NoSuchElementException();
}

}

public void remove() {
MyArrayList.this.remove(init-1);
init--;
}
};
return it;
}

public int lastIndexOf(Object o) {
// TODO Auto-generated method stub
return 0;
}

public ListIterator listIterator() {
// TODO Auto-generated method stub
return null;
}

public ListIterator listIterator(int index) {
// TODO Auto-generated method stub
return null;
}

public Object remove(int index) {
if(index<count){
Object obj=data[index];
for(int i=index;i<count-1;i++){
data[i]=data[i+1];
}
data[count-1]=null;
count--;
return obj;
}else{
throw new IndexOutOfBoundsException("指定下标越界");
}
}

public boolean remove(Object o) {
if(this.contains(o)){
int i=this.indexOf(o);
this.remove(i);
return true;
}
return false;
}

public boolean removeAll(Collection c) {
// TODO Auto-generated method stub
return false;
}

public boolean retainAll(Collection c) {
// TODO Auto-generated method stub
return false;
}

public Object set(int index, Object element) {
if(index<count){
Object obj=data[index];
data[index]=element;
return obj;
}else{
throw new IndexOutOfBoundsException("指定下标越界");
}

}

public int size() {

return count;
}

public List subList(int fromIndex, int toIndex) {
// TODO Auto-generated method stub
return null;
}

public Object[] toArray() {
Object[] obj=new Object[count];
for(Object o:data){
int i=0;
obj[i]=o;
i++;
}
return obj;
}

public Object[] toArray(Object[] a) {
// TODO Auto-generated method stub
return null;
}

}

自己以前写的MyArrayList,希望能给LZ点帮助,其实集合类很好写,LZ也可以先赵本数据结构的书,上面都有很多的例子
给LZ推荐一本http://book.csdn.net/hi/BookClub_BookDetails.aspx?id=30400
里面有很多作者写的包
goodmrning 2009-09-14
  • 打赏
  • 举报
回复
ding!
pangxie887 2009-09-14
  • 打赏
  • 举报
回复
Most of the methods you will need to implement are described below; for more detailed
information, see the JavaDoc of the RankBag interface in the BlueJ project provided.
add(E o) Adds o to the bag.
contains(Object o) Returns true if the bag contains o.
getCount(Object o) Returns how many times o has been added to the
bag.
remove(Object o) Removes all instances of o from the bag.
removeOnce(Object o) Removes one instance of o from the bag.
size() Returns the number of elements in the bag (the cardinality).
uniqueSet() Returns a new Set of all elements in this bag with no
duplicate entries.
first() Returns the first (lowest) element currently in the
bag.
second() Returns the second smallest item in the bag.
kth() Returns the kth smallest item in the bag. For example,
k = 2 is the same as the second-smallest.
You should test your implementation using the supplied JUnit tests attached to the
RankBagArray class (where you will write your implementation). You can run these
tests by right-clicking on the RankBagArrayTest class and choosing Test All.
加载更多回复(3)
最近正在学习Java,也买了很多的有关Java方面的书籍,其中发现《跟我学Java》这本书,都的很不错啊,所以顺便拿电脑把这本书的目录敲了下来,与大家分享。尤其是那些和我一样初学Java的朋友们,看看哪一节对你有用,不妨过来讨论一下哦! 第1章 Java概述 1.1 Java的发展史 1.1.1 Java起源 1.1.2 Java发展 1.2 Java是什么 1.2.1 Java语言 1.2.2 Java平台 1.2.3 Java网络操作系统 1.3 Java的特点 1.4 Java程序类型 1.5 JDK与JRE 1.5.1 Java开发工具包 1.5.2 Java运行环境 1.6 Java技术体系 1.7 Java虚拟机 1.7.1 虚拟机数据类型 1.7.2 Java虚拟机的生命周期 1.7.3 Java虚拟机的体系结构 1.8 垃圾收集器 1.9 本章习题 第2章 Java开发环境 2.1 J2SE的下载和安装 2.1.1 J2SE的下载 2.1.2 J2SE的安装 2.2 环境变量的配置与测试 2.2.1 设置环境变量path 2.2.2 设置环境变量classpath 2.2.3 环境变量的测试 2.3 API文档的下载与使用 2.4 第一个应用程序 2.4.1 HelloWorld程序 2.4.2 程序运行编译命令 2.4.3 HelloWorld编译与运行 2.5 简单开发工具介绍 2.5.1 EditPlus的编译与运行 2.5.2 在UltraEdit上开发Java 2.6 集成开发环境Eclipse介绍 2.6.1 Eclipse下载与安装 2.6.2 Eclipse的透视图 2.6.3 Eclipse的视图(View) 2.6.4 Eclipse的编辑器 2.6.5 Eclipse的工具栏和菜单栏 2.6.6 使用Eclipse编写HelloWorld程序 2.7 本章习题 第3章 Java语言基础 3.1 标识符 3.1.1 标识符的概念 3.1.2 变量命名规则 3.1.3 变量命名技巧 3.2 关键字 3.3 注释 3.4 数据类型 3.4.1 整型 3.4.2 浮点型 3.4.3 字符型 3.4.4 布尔型 3.5 变量与常量 3.5.1 变量声明 3.5.2 变量赋值和初始化 3.5.3 常量 3.6 类型转化 3.6.1 数值类型之间的转换 3.6.2 强制类型转换 3.7 运算符 3.7.1 算术运算符 3.7.2 关系运算符 3.7.3 逻辑运算符 3.7.4 位运算符 3.7.5 自动递增和递减 3.7.6 三元运算符 3.7.7 运算符的优先级 3.8 本章习题 第4章 程序流程控制 4.1 顺序结构 4.2 条件语句 4.2.1 if语句 4.2.2 if-else语句 4.2.3 if-else-if语句 4.2.4 if语句的嵌套 4.2.5 布尔表达式 4.2.6 开关语句 4.3 循环语句 4.3.1 while循环结构 4.3.2 do-while 循环结构 4.3.3 for循环结构 4.3.4 循环的嵌套 4.4 转向语句 4.4.1 break中断语句 4.4.2 continue条件继续语句 4.4.3 标签语句 4.5 返回语句 4.6 综合实例:水仙花数 4.7 本章习题 第5章 字符串 5.1 字符串简介 5.1.1 字符串常量 5.1.2 String创建字符串常量 5.1.3 StringBuffer创建字符串 5.2 连接字符串 5.2.1 与字符串的连接 5.2.2 与其他数据类型的连接 5.3 String字符串操作 5.3.1 基本操作 5.3.2 比较 5.3.3 转化 5.3.4 查找 5.3.5 截取拆分 5.3.6 替换或修改 5.4 StringBuffer类操作 5.4.1 基本操作 5.4.2 字符串操作方法 5.4.3 添加append() 5.4.4 插入insert() 5.5 实例:字符串应用 5.6 本章习题 第6章 数组 6.1 一
跟我学Java_Web配套源代码,全书全!另外: Java Web开发是目前最流行、使用最广泛的网站开发技术。《跟我学Java Web》通过对Java Web开发中所运用到的各种技术循序渐进地进行讲解,使读者能尽快掌握开发Web应用程序的方法。《跟我学Java Web》内容包括搭建Web开发环境、HTML相关技术基础知识、JavaScript相关技术基础知识、JSP技术基础知识、Servlet技术基础知识、搭建MySQL数据库开发环境、JDBC技术、JavaBean技术基础知识、Ajax技术基础知识、Struts2技术详解(拦截器、输入校验、国际化、Struts2的各种标签、对Ajax的支持等)、Spring2.5(容器、装配Java Bean、JDBC和Hibernate模板等)以及Hibernate3技术详解(会话、映射、HQL等)。除此之外,第11、第14章还提供了两个完整的实例来讲解Struts2开发新特性和开发SSH的详细步骤.通过对这两章的学习,读者可以对SSH开发模式有更透彻的理解和认识。《跟我学Java Web》光盘中提供了丰富的内容,包括全书的多媒体视频演示、全书的电子教案、900多页的电子资料以及书中讲解的源代码等。每章后面的习题均有相应的解答,读者可以到网站下载。《跟我学Java Web》适合广大Java Web初学者、初步掌握Java技术的读者,想深入学习Struts2、SSH框架的开发者,以及从事Java Web开发工作的技术人员。
图文并茂很适合初学着学习 下面是课程的目录: 第一篇 基础篇   第1章 Java简介(精彩视频:33分钟) 21   1.1 Java的平台简介 21   1.2 安装工具包 22   1.2.1 下载JDK 22   1.2.2 安装JDK 24   1.2.3 查看与设置环境变量 25   1.2.4 JDK常用命令 27   1.2.5 Java各个目录含义 28   1.2.6 要善于使用JDK的帮助文件 28   1.3 程序开发过程 29   1.4 编码规范 29   1.5 HelloWorld:第一个Java程序 30   1.5.1 编写程序代码 30   1.5.2 编译程序代码并运行 30   1.5.3 注意事项 31   1.6 使用Eclipse集成开发工具开发 32   1.7 综合练习 32   1.8 小结 33   1.9 习题 33   第2章 Java的基本数据类型(精彩视频:38分钟) 34   2.1 数据类型 34   2.1.1 整型 34   2.1.2 浮点型 35   2.1.3 字符型(char) 36   2.1.4 布尔型(boolean) 36   2.2 数据类型间的转换 36   2.2.1 自动转换 36   2.2.2 强制转换 37   2.2.3 隐含转换 37   2.3 标识符的命名 38   2.3.1 标识符的命名规则 38   2.3.2 代码演示如何定义标识符 38   2.3.3 不好的标识符命名 38   2.3.4 良好的标识符命名 39   2.4 关键字 39   2.5 代码注释 40   2.5.1 行注释 40   2.5.2 块注释 41   2.5.3 文档注释用户自定义类型 41   2.6 综合练习 43   2.7 小结 43   2.8 习题 43   第3章 运算符(精彩视频:43分钟) 45   3.1 算术运算符 45   3.1.1 “+”:加法运算符 45   3.1.2 “-”:减法运算符 46   3.1.3 “*”:乘法运算符 47   3.1.4 “/”:除法运算符 48   3.1.5 “%”:求余运算符 48   3.2 自增自减运算符 49   3.3 关系运算符 51   3.3.1 “==”、“!=” 51   3.3.2 “>”、“<”、“>=”、“<=” 52   3.4 逻辑运算符 53   3.4.1 “&&”:与运算符 53   3.4.2 “||”:或运算符 53   3.4.3 “!”:非运算符 54   3.4.4 逻辑运算符总结 54   3.5 三元运算符 55   3.6 位运算符 55   3.6.1 “&”:按位与运算符 56   3.6.2 “|”:按位或运算符 56   3.6.3 “^”:按位异或运算符 57   3.7 位移运算符 57   3.7.1 “>>”:带符号右移运算符 58   3.7.2 “<<”:带符号左移运算符 58   3.7.3 “>>>”:无符号右移运算符 58   3.8 赋值运算符 59   3.8.1 一般赋值运算符 59   3.8.2 运算赋值运算符 59   3.9 运算符之间的优先级 60   3.10 综合练习 61   3.11 小结 62   3.12 习题 62   第4章 流程控制(精彩视频:58分钟) 64   4.1 if条件语句 64   4.1.1 if语句的语法 64   4.1.2 if语句用法举例 64   4.2 switch分支语句 67   4.2.1 switch分支语句的语法 67   4.2.2 switch分支语句表达式的使用条件 68   4.2.3 switch分支语句举例 70   4.3 while循环语句 72   4.3.1 while循环语句的语法 72   4.3.2 while循环语句举例 73   4.4 do...while循环语句 73   4.4.1 do...while循环语句的语法 74   4.4.2 do ... while循环语句举例 74   4.5 for循环语句 75   4.5.1 for循环语句的语法 75   4.5.2 用for循环来实现其他循环语句 76   4.5.3 for循环语句的举例 77   4.6 如何中断和继续语句的执行 78   4.6.1 break:中断语句执行 78   4.6.2 continue:继续语句执行 79   4.7 综合练习 79   4.8 小结 80   4.9 习题 81   第5章 数组(精彩视频:52分钟) 83   5.1 如何创建数组 83   5.1.1 创建数组 83   5.1.2 创建多维数组 84   5.2 数组的初始化 85   5.2.1 创建并初始数组元素 85   5.2.2 循环初始化 87   5.3 数组操作的举例 88   5.3.1 数组元素值的复制 88   5.3.2 数组元素的排序 90   5.3.3 在数组里查找指定元素 91   5.3.4 利用数组打印26个英文字母 92   5.4 综合练习 93   5.5 小结 94   5.6 习题 94   第二篇 面向对象篇   第6章 类与对象(精彩视频:48分钟) 96   6.1 什么是面向对象 96   6.1.1 面向对象编程的特点 96   6.1.2 面向对象编程与面向过程编程的区别 97   6.2 什么是类 97   6.2.1 类的定义和对象的创建 97   6.2.2 如何使用现有类 99   6.2.3 类设计的技巧 100   6.3 成员变量 101   6.3.1 成员变量的创建 101   6.3.2 成员变量的初始化 102   6.4 局部变量 105   6.4.1 局部变量的创建和初始化 105   6.4.2 局部变量和成员变量的区别 106   6.5 方法 106   6.5.1 方法的创建和参数 106   6.5.2 方法参数的传递 108   6.6 对象引用的使用 110   6.6.1 调用不存在的对象或成员变量 110   6.6.2 调用对象为null值的引用 111   6.6.3 对象引用间的比较 113   6.7 this 113   6.8 要活用JDK已有的类 114   6.8.1 Date类 114   6.8.2 Integer类 116   6.9 综合练习 117   6.10 小结 118   6.11 习题 118   第7章 控制逻辑(精彩视频:50分钟) 120   7.1 包(package) 120   7.1.1 创建一个包 120   7.1.2 如何使用包 121   7.1.3 什么是静态引入 122   7.2 类的访问级别 123   7.2.1 公开的访问级别 123   7.2.2 默认的访问级别 124   7.3 什么是封装 125   7.4 最终修饰符 127   7.4.1 final修饰对象类型的成员变量 127   7.4.2 final修饰基本类型的成员变量 129   7.4.3 final修饰的局部变量 131   7.4.4 final修饰的方法 132   7.5 静态修饰符 134   7.5.1 什么是静态变量 134   7.5.2 静态变量的访问 135   7.5.3 什么是静态常量 137   7.6 综合练习 139   7.7 小结 140   7.8 习题 140   第8章 继承(精彩视频:72分钟) 141   8.1 什么是继承 141   8.1.1 类的继承 142   8.1.2 继承的语法 145   8.2 修饰符 146   8.2.1 public:声明成员变量为公共类型 146   8.2.2 private:声明成员变量为私有类型 147   8.2.3 default:声明成员变量为默认类型 148   8.2.4 protected:声明成员变量为保护类型 149   8.3 成员变量的覆盖 150   8.4 对象引用 151   8.5 方法的重写和重载 152   8.5.1 方法重写的特点 152   8.5.2 方法重载的特点 154   8.5.3 重写的返回类型 156   8.5.4 重写是基于继承的 158   8.5.5 静态方法是不能重写的 159   8.5.6 三者之间的关系 161   8.5.7 重写toString方法 162   8.5.8 重写equals方法 163   8.6 final与继承的关系 164   8.7 abstract与继承的关系 165   8.8 什么是多态 166   8.9 什么是枚举类 168   8.10 什么是反射机制 169   8.11 什么是泛型 170   8.12 综合练习 172   8.13 小结 172   8.14 习题 172   第9章 接口(精彩视频:47分钟) 174   9.1 什么是接口 174   9.1.1 接口的定义 174   9.1.2 访问接口里的常量 176   9.2 接口的使用 177   9.2.1 接口里的方法如何创建 177   9.2.2 接口引用怎么使用 178   9.3 什么是抽象类 180   9.3.1 抽象类的使用和特点 180   9.3.2 抽象类与接口区别 183   9.4 接口的多态 183   9.5 判断类型 185   9.5.1 什么是instanceof 185   9.5.2 使用instanceof的注意事项 188   9.6 综合练习 189   9.7 小结 189   9.8 习题 189   第10章 构造器(精彩视频:46分钟) 191   10.1 什么是构造器 191   10.1.1 构造器的使用 191   10.1.2 被修饰的构造器 193   10.1.3 构造器方法与普通方法的区别 196   10.2 如何实例化一个对象 197   10.3 构造器的使用 199   10.3.1 构造器的调用 199   10.3.2 构造器重载 202   10.3.3 父子类间的构造器的调用流程 204   10.3.4 如何自定义构造器 207   10.4 什么是单子模式 208   10.5 构造器在程序中是何时运行的 211   10.6 综合练习 214   10.7 小结 215   10.8 习题 215   第11章 异常处理(精彩视频:60分钟) 217   11.1 异常处理基本介绍 217   11.1.1 try和catch捕获异常 217   11.1.2 try-catch语句使用注意点 218   11.1.3 finally语句的使用 220   11.1.4 再谈异常处理注意点 222   11.2 异常的分类 223   11.2.1 捕获异常 223   11.2.2 未捕获异常 225   11.3 抛出异常 225   11.3.1 抛出异常的简单介绍 225   11.3.2 使用throws和throw语句抛出异常 227   11.4 自定义异常 227   11.4.1 创建和使用自定义异常类 227   11.4.2 自定义异常的实际应用 228   11.5 综合练习 231   11.6 小结 232   11.7 习题 232   第12章 内部类(精彩视频:71分钟) 234   12.1 非静态内部类 234   12.1.1 创建非静态内部类 234   12.1.2 在外部类中访问内部类 235   12.1.3 在外部类外访问内部类 236   12.1.4 在内部类中访问外部类 237   12.2 局部内部类 240   12.2.1 创建局部内部类 240   12.2.2 在局部内部类中访问外部类成员变量 240   12.2.3 在局部内部类中访问外部类的局部变量 241   12.2.4 静态方法中的局部内部类 243   12.3 静态内部类 244   12.3.1 创建静态内部类 244   12.3.2 在外部类中访问静态内部类 245   12.3.3 在外部类外访问静态内部类 246   12.4 匿名内部类 247   12.4.1 创建匿名内部类 247   12.4.2 匿名内部类的初始化 249   12.5 综合练习 250   12.6 小结 250   12.7 习题 250   第13章 多线程(精彩视频:55分钟) 252   13.1 多线程简介 252   13.2 定义线程和创建线程对象 252   13.2.1 继承Thread类定义线程 252   13.2.2 实现Runnable接口定义线程 253   13.3 运行线程 254   13.3.1 启动线程 254   13.3.2 同时运行多个线程 256   13.4 线程生命周期 257   13.4.1 新建状态 257   13.4.2 准备状态 257   13.4.3 运行状态 257   13.4.4 等待/阻塞状态 258   13.4.5 死亡状态 258   13.5 线程的调度 258   13.5.1 睡眠方法 258   13.5.2 线程优先级 260   13.5.3 yield让步方法 261   13.5.4 join让步方法 262   13.6 综合练习 264   13.7 小结 265   13.8 习题 265   第三篇 应用篇   第14章 Swing桌面程序开发(精彩视频:70分钟) 268   14.1 开发第一个Swing程序 268   14.2 JFrame窗口类 269   14.2.1 JFrame窗口类简介 269   14.2.2 创建简单窗体 269   14.2.3 设置窗体 271   14.3 JPanel面板类 273   14.3.1 容器介绍 273   14.3.2 JPanel面板类简介 274   14.3.3 创建面板 274   14.4 JLabel标签类 275   14.4.1 JLabel标签类简介 275   14.4.2 创建标签 276   14.5 JButton按钮类 276   14.5.1 JButton按钮类简介 277   14.5.2 创建按钮 277   14.5.3 按钮动作事件 278   14.6 Swing中的事件 280   14.6.1 事件简介 280   14.6.2 同一个事件源注册多个监听器 280   14.6.3 同一个监听器注册给多个事件源 282   14.6.4 窗体获取和失去焦点事件 283   14.6.5 窗体打开、关闭和激活事件 284   14.7 综合练习 286   14.8 小结 288   14.9 习题 288   第15章 布局管理器(精彩视频:62分钟) 290   15.1 流布局 290   15.1.1 流布局介绍 290   15.1.2 使用流布局 291   15.2 网格布局 293   15.2.1 网格布局介绍 293   15.2.2 使用网格布局 293   15.3 边框布局 295   15.3.1 边框布局介绍 296   15.3.2 使用边框布局 296   15.4 空布局 298   15.4.1 空布局介绍 298   15.4.2 使用空布局 298   15.5 卡片布局 299   15.5.1 卡片布局介绍 299   15.5.2 使用卡片布局 300   15.6 综合练习 302   15.7 小结 304   15.8 习题 304   第16章 Swing常用控件(精彩视频:90分钟) 306   16.1 文本框及密码框和多行文本框 306   16.1.1 创建文本框 306   16.1.2 创建密码框 307   16.1.3 创建多行文本框 309   16.2 复选框和单选按钮 310   16.2.1 创建单选按钮 310   16.2.2 创建复选框 313   16.3 选项卡 315   16.3.1 选项卡介绍 315   16.3.2 创建选项卡 315   16.4 分隔窗格 317   16.4.1 分隔窗格介绍 317   16.4.2 创建分隔窗格 317   16.5 滑块和进度条 319   16.5.1 创建滑块 319   16.5.2 创建进度条 320   16.6 列表框 323   16.6.1 列表框介绍 323   16.6.2 创建列表框 324   16.6.3 下拉列表框 326   16.7 菜单 328   16.7.1 菜单介绍 328   16.7.2 创建菜单 329   16.7.3 创建弹出式菜单 330   16.8 综合练习 330   16.9 小结 332   16.10 习题 333   第17章 JDBC数据库编程(精彩视频:63分钟) 335   17.1 数据库基本介绍 335   17.1.1 数据库介绍 335   17.1.2 数据库应用架构 335   17.1.3 数据库模型 336   17.2 JDBC数据库编程介绍 336   17.2.1 JDBC和ODBC的关系 337   17.2.2 为什么使用JDBC数据库编程 337   17.3 SQL数据库操作技术 338   17.3.1 什么是SQL 338   17.3.2 如何进行SQL操作 338   17.4 创建数据库 339   17.4.1 创建Access数据库 339   17.4.2 创建SQL Server数据库 339   17.5 JDBC编程步骤 342   17.5.1 创建数据源 342   17.5.2 加载驱动程序 344   17.5.3 建立数据库连接 345   17.5.4 进行数据库操作 345   17.5.5 获取数据库中信息 346   17.5.6 JDBC数据库编程实例 347   17.6 事务处理 348   17.6.1 事务介绍 348   17.6.2 进行事务操作 349   17.7 综合练习 351   17.8 小结 352   17.9 习题 352   第18章 Java中输入/输出流(精彩视频:55分钟) 353   18.1 I/O流简介 353   18.1.1 什么是I/O流 353   18.1.2 节点流与处理流 353   18.1.3 字节流与字符流 354   18.1.4 抽象基类 354   18.2 使用流进行文件操作 356   18.2.1 使用File类进行文件与目录操作 356   18.2.2 FileInputStream类与FileOutputStream类 359   18.2.3 FileReader类与FileWriter类 362   18.3 综合练习 364   18.4 小结 364   18.5 习题 364   第19章 集合框架(精彩视频:65分钟) 366   19.1 集合框架总论 366   19.1.1 什么是集合框架 366   19.1.2 Collection接口 366   19.2 列表 367   19.2.1 List列表接口 367   19.2.2 Vector类 368   19.2.3 ArrayList类 371   19.2.4 LinkedList类 373   19.3 集合 376   19.3.1 Set接口 376   19.3.2 SortedSet接口 377   19.3.3 TreeSet类 378   19.3.4 HashSet类 380   19.4 映射 381   19.4.1 Map接口 381   19.4.2 HashMap类 382   19.4.3 TreeMap类 384   19.5 综合练习 385   19.6 小结 386   19.7 习题 387   第20章 网络编程(精彩视频:58分钟) 389   20.1 网络编程基础 389   20.1.1 TCP/IP协议 389   20.1.2 网络编程模型 389   20.1.3 网络传输协议 390   20.1.4 端口和套接字 390   20.2 基于TCP/IP协议的网络编程 391   20.2.1 Socket套接字 391   20.2.2 ServerSocket类 391   20.2.3 Socket类 392   20.2.4 网络编程C/S架构实例 393   20.3 综合练习 396   20.4 小结 398   20.5 习题 398   第四篇 综合案例篇   第21章 学生管理系统(精彩视频:54分钟) 399   21.1 系统设计 399   21.2 数据库设计 399   21.3 登录界面开发 400   21.3.1 界面设计 400   21.3.2 程序开发 400   21.4 学生界面开发 402   21.4.1 界面设计 402   21.4.2 程序开发 402   21.4.3 开发插入学生界面 403   21.4.4 查询学生信息界面 406   21.4.5 查询成绩信息 409   21.5 综合练习 412   21.6 小结 413

62,614

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧