分享一个大牛的人工智能教程。零基础!通俗易懂!风趣幽默!希望你也加入到人工智能的队伍中来!请点击http://www.captainbed.net
1. Introduction
Java Generics were introduced in JDK 5.0 with the aim of reducing bugs and adding an extra layer of abstraction over types.
This article is a quick intro to Generics in Java, the goal behind them and how they can be used to improve the quality of our code.
2. The Need for Generics
Let's imagine a scenario where we want to create a list in Java to store Integer ; we can be tempted to write:
List list = new LinkedList();
list.add(new Integer(1));
Integer i = list.iterator().next();
Surprisingly, the compiler will complain about the last line. It doesn't know what data type is returned. The compiler will require an explicit casting:
Integer i = (Integer) list.iterator.next();
There is no contract that could guarantee that the return type of the list is an Integer. The defined list could hold any object. We only know that we are retrieving a list by inspecting the context. When looking at types, it can only guarantee that it is an Object , thus requires an explicit cast to ensure that the type is safe.
This cast can be annoying, we know that the data type in this list is an Integer . The cast is also cluttering our code. It can cause type-related runtime errors if a programmer makes a mistake with the explicit casting.
It would be much easier if programmers could express their intention of using specific types and the compiler can ensure the correctness of such type. This is the core idea behind generics.
Let's modify the first line of the previous code snippet to:
List list = new LinkedList<>();
By adding the diamond operator <> containing the type, we narrow the specialization of this list only to Integer type i.e. we specify the type that will be held inside the list. The compiler can enforce the type at compile time.
In small programs, this might seem like a trivial addition, however, in larger programs, this can add significant robustness and makes the program easier to read.
3. Generic Methods
Generic methods are those methods that are written with a single method declaration and can be called with arguments of different types. The compiler will ensure the correctness of whichever type is used. These are some properties of generic methods:
Generic methods have a type parameter (the diamond operator enclosing the type) before the return type of the method declaration
Type parameters can be bounded (bounds are explained later in the article)
Generic methods can have different type parameters separated by commas in the method signature
Method body for a generic method is just like a normal method
An example of defining a generic method to convert an array to a list:
public List fromArrayToList(T[] a) {
return Arrays.stream(a).collect(Collectors.toList());
}
In the previous example, the in the method signature implies that the method will be dealing with generic type T . This is needed even if the method is returning void.
As mentioned above, the method can deal with more than one generic type, where this is the case, all generic types must be added to the method signature, for example, if we want to modify the above method to deal with type T and type G , it should be written like this:
public static List fromArrayToList(T[] a, Function mapperFunction) {
return Arrays.stream(a)
.map(mapperFunction)
.collect(Collectors.toList());
}
We're passing a function that converts an array with the elements of type T to list with elements of type G. An example would be to convert Integer to its String representation:
@Test
public void givenArrayOfIntegers_thanListOfStringReturnedOK() {
Integer[] intArray = {1, 2, 3, 4, 5};
List stringList
= Generics.fromArrayToList(intArray, Object::toString);
assertThat(stringList, hasItems("1", "2", "3", "4", "5"));
}
It is worth noting that Oracle recommendation is to use an uppercase letter to represent a generic type and to choose a more descriptive letter to represent formal types, for example in Java Collections T is used for type, K for key, V for value.
3.1. Bounded Generics
As mentioned before, type parameters can be bounded. Bounded means “restricted “, we can restrict types that can be accepted by a method.
For example, we can specify that a method accepts a type and all its subclasses (upper bound) or a type all its superclasses (lower bound).
To declare an upper bounded type we use the keyword extends after the type followed by the upper bound that we want to use. For example:
public List fromArrayToList(T[] a) {
...
}
The keyword extends is used here to mean that the type T extends the upper bound in case of a class or implements an upper bound in case of an interface.
3.2. Multiple Bounds
A type can also have multiple upper bounds as follows:
If one of the types that are extended by T is a class (i.e Number ), it must be put first in the list of bounds. Otherwise, it will cause a compile-time error.
4. Using Wildcards with Generics
Wildcards are represented by the question mark in Java “? ” and they are used to refer to an unknown type. Wildcards are particularly useful when using generics and can be used as a parameter type but first, there is an important note to consider.
It is known that Object is the supertype of all Java classes, however, a collection of Object is not the supertype of any collection.
For example, a List is not the supertype of List and assigning a variable of type List to a variable of type List will cause a compiler error. This is to prevent possible conflicts that can happen if we add heterogeneous types to the same collection.
The Same rule applies to any collection of a type and its subtypes. Consider this example:
public static void paintAllBuildings(List buildings) {
buildings.forEach(Building::paint);
}
if we imagine a subtype of Building , for example, a House , we can't use this method with a list of House , even though House is a subtype of Building . If we need to use this method with type Building and all its subtypes, then the bounded wildcard can do the magic:
public static void paintAllBuildings(List buildings) {
...
}
Now, this method will work with type Building and all its subtypes. This is called an upper bounded wildcard where type Building is the upper bound.
Wildcards can also be specified with a lower bound, where the unknown type has to be a supertype of the specified type. Lower bounds can be specified using the super keyword followed by the specific type, for example, means unknown type that is a superclass of T (= T and all its parents).
5. Type Erasure
Generics were added to Java to ensure type safety and to ensure that generics wouldn't cause overhead at runtime, the compiler applies a process called type erasure on generics at compile time.
Type erasure removes all type parameters and replaces it with their bounds or with Object if the type parameter is unbounded. Thus the bytecode after compilation contains only normal classes, interfaces and methods thus ensuring that no new types are produced. Proper casting is applied as well to the Object type at compile time.
This is an example of type erasure:
public List genericMethod(List list) {
return list.stream().collect(Collectors.toList());
}
With type erasure, the unbounded type T is replaced with Object as follows:
// for illustration
public List withErasure(List list) {
return list.stream().collect(Collectors.toList());
}
// which in practice results in
public List withErasure(List list) {
return list.stream().collect(Collectors.toList());
}
If the type is bounded, then the type will be replaced by the bound at compile time:
public void genericMethod(T t) {
...
}
would change after compilation:
public void genericMethod(Building t) {
...
}
6. Generics and Primitive Data Types
A restriction of generics in Java is that the type parameter cannot be a primitive type.
For example, the following doesn't compile:
List list = new ArrayList<>();
list.add(17);
To understand why primitive data types don't work, let's remember that generics are a compile-time feature , meaning the type parameter is erased and all generic types are implemented as type Object .
As an example, let's look at the add method of a list:
List list = new ArrayList<>();
list.add(17);
The signature of the add method is:
boolean add(E e);
And will be compiled to:
boolean add(Object e);
Therefore, type parameters must be convertible to Object . Since primitive types don't extend Object , we can't use them as type parameters.
However, Java provides boxed types for primitives, along with autoboxing and unboxing to unwrap them:
Integer a = 17;
int b = a;
So, if we want to create a list which can hold integers, we can use the wrapper:
List list = new ArrayList<>();
list.add(17);
int first = list.get(0);
The compiled code will be the equivalent of:
List list = new ArrayList<>();
list.add(Integer.valueOf(17));
int first = ((Integer) list.get(0)).intValue();
Future versions of Java might allow primitive data types for generics.
7. Conclusion
Java Generics is a powerful addition to the Java language as it makes the programmer's job easier and less error-prone. Generics enforce type correctness at compile time and, most importantly, enable implementing generic algorithms without causing any extra overhead to our applications.
你可能感兴趣的:(Java)
Java 循环结构进阶
m0_74824483
面试 学习路线 阿里巴巴 java
二重循环1.一个循环体内又包含另一个完整的循环结构2.外城循环变量变化一次,内层循环变量要变化一遍。二重循环-冒泡排序
Java--IO流详解 (上)--字符流
不修×蝙蝠
IO流 JavaSE 输入流 输出流 字节流 字符流
目录IO流的概念字符流输入流Reader核心方法1.close()2.mark(intreadAheadLimit)3.markSupported()4.read()5.read(char[]cbuf)6.read(char[]cbuf,intoff,intlen)7.read(CharBuffertarget)8.ready()9.reset()10.skip(longn)Reader的常用子类
JavaScript 中内存泄漏的几种情况是什么,如何避免?
程序员黄同学
前端开发 JavaScript Java面试题 javascript 前端 开发语言
一、全局变量泄漏(高频考点)问题场景:未使用var/let/const声明变量,或意外挂载到window对象//错误示例(创建全局变量)functioninitData(){cache=newArray(1000000)//隐式全局变量}//正确方案(严格模式+局部变量)'usestrict'functionsafeInit(){constlocalCache=[]//局部变量自动回收}防御建议:
自定义公式校验规则、常用的JavaScript正则公式合法校验、自定义公式合集、前端校验规则、字符串校验
a_dream(前端)
前端 javascript 正则表达式
vue开发中,会使用到自定义公式校验合法性,判断公式是否符合逻辑,整理个人使用过的自定义公式页面保存时对输入的字符串进行校验的一套规则(文章最后有完整代码)目录1.正则判断2.校验数字(输入数字不超过十位数,不超过两位小数)3.校验括号(嵌套括号是否符合要求)4.(完整代码文件)1.正则判断constre=/[^0-9\(\)\+\-\×\÷\.\#\{\}]{1,}///判断输入字符合法性的正则
IDEA配置JSTL
阿俊仔(摸鱼版)
intellij-idea java tomcat
IDEA配置JSTL下载JSTL官网下载地址:https://tomcat.apache.org翻到下面找到:点击,download下载下面内容:(就Impl和Spec)配置JSTL将两个下好的jar包放在lib文件夹下ctrl+shift+alt+s打开ProjectStructure左侧找到Modules->右侧选择Dependences->点击➕号Library->点击java->选中WEB
javax.imageio.IIOException: Can‘t read input file
阿俊仔(摸鱼版)
眼盲心不瞎的憨憨bug日记 intellij-idea
问题描述根据路径地址读取图片存入数据库时,提示我没法读取图片。原因分析:大致就是各种情况导致路径不对或者文件不对路径格式写错了(windows路径分隔符是\,Linux是/)文件格式写错(文件名写错或者文件后缀写错)该路径下此文件不存在(复制路径去本地找找核对一下)解决方案:先看报错信息检查出错的语句(那边没什么问题),然后我又检查了所有写了文件路径的语句,发现我写入数据库的那个文件的路径没把文件
MVC和react
吃蛋糕的居居
javascript css node.js html
MVC1.MVC是一种使用MVC(ModelViewController模型-视图-控制器)设计创建Web应用程序的模式.(1)Model(模型)表示应用程序核心(比如数据库记录列表).(2)View(视图)显示数据(数据库记录).(3)Controller(控制器)处理输入(写入数据库记录).2.MVC模式同时提供了对HTML、CSS和JavaScript的完全控制.(1)Model(模式)是应
海南大学--学习资料--网络应用开发java web(胡祝华)-第3次作业解析(学长整理)
创创大帝(水印很浅-下载的文档)
海南大学--学习资料--PHP HTML java web 前端 java html
海南大学–学习资料–网络应用开发javaweb(胡祝华)-第3次作业解析(学长整理)海南大学–学习资料–网络应用开发javaweb(胡祝华)-第3次作业解析(学长整理)海南大学–学习资料–网络应用开发javaweb(胡祝华)-第3次作业解析(学长整理)表单验证:1.在表单的源码中head部分用script导入了script/regcheckdata.js文件2.当点击提交按钮时,onSubmit=
手把手教你给 windows装个vmware虚拟机
python算法小白
附Java/C/C++/机器学习/算法与数据结构/前端/安卓/Python/程序员必读书籍书单大全:书单导航页(点击右侧极客侠栈即可打开个人博客):极客侠栈①【Java】学习之路吐血整理技术书从入门到进阶最全50+本(珍藏版)②【算法数据结构+acm】从入门到进阶吐血整理书单50+本(珍藏版)③【数据库】从入门到进阶必读18本技术书籍网盘吐血整理网盘(珍藏版)④【Web前端】从HTML到JS到AJ
github提示 Filename too long
JavaGameServer
# git rocketmq
gitconfig--globalcore.longpathstrueerror:open("chapter13/rocketmq-externals-master/rocketmq-externals-master/rocketmq-connect/rocketmq-connect-runtime/src/test/java/org/apache/rocketmq/connect/runtime
利用IDEA将Java.class文件反编译为Java文件:原理、实践与深度解析
.猫的树
Java反编译 IDEA技巧 逆向工程
文章目录引言:当.class文件遇到源代码缺失第一章:反编译技术基础认知1.1Java编译执行原理1.2反编译的本质1.3法律与道德边界第二章:IDEA内置反编译工具详解2.1环境准备2.2三步完成基础反编译2.3高级反编译技巧2.3.1调试模式反编译2.3.2Lambda表达式处理2.3.3泛型类型恢复第三章:Fernflower反编译引擎深度配置3.1引擎参数调优3.2多文件批量反编译3.3结
Java微服务技术栈(2)
Z-H-J
Java笔记随录 java 微服务 开发语言
写在前面高级篇里的很多知识我都没有去实践过,只是知道相关的原理,主要原因是:应用场景在多数情况下难以碰见(高并发)对于运行的要求过高(如果是单节点进行模拟,那么就必须有很大的运行内存)所以这部分记录更多是一个思路的梳理,可能无法作为各位全面掌握该部分知识的条目,望见谅7.微服务的保护技术:Sentinelsentiel分为sentinel控制台和sentinel客户端,具体的规则过滤都由配置在微服
scala kotlin比较_追随 Kotlin/Scala,看 Java 12-15 的现代语言特性
weixin_39605296
scala kotlin比较 scala list 接受java string
本文原发于我的个人博客:https://hltj.me/java/2020/06/14/java-12-15-lang-features.html。本副本只用于知乎,禁止第三方转载。Java14发布已经过去了三个月,Java15目前也已经到了“RampdownPhaseOne”阶段,其新特性均已敲定。由于12-15都是短期版本,无需考虑也不应该将其用于生产环境。但可以提前了解新特性,以免在下一个L
java 协程 scala_追随 Kotlin/Scala,看 Java 12-15 的现代语言特性
小田linda
java 协程 scala
Java14发布已经过去了三个月,Java15目前也已经到了“RampdownPhaseOne”阶段,其新特性均已敲定。由于12-15都是短期版本,无需考虑也不应该将其用于生产环境。但可以提前了解新特性,以免在下一个LTS(Java17)正式发布时毫无心理准备。Java12-15引入了一系列改进,本文只讨论语言层面的新特性,它们看起来似曾相识——没错,这些特性让人感觉Java在沿Kotlin/Sc
VS Code 中如何运行Java SpringBoot的项目
战族狼魂
java Springboot java spring boot 开发语言
在VisualStudioCode(VSCode)中运行JavaSpringBoot项目需要以下步骤:目录1.安装必要的扩展2.配置环境3.创建或导入SpringBoot项目使用SpringInitializr创建新项目导入现有项目4.配置VSCode配置调试环境5.运行和调试项目通过命令行运行通过SpringBootDashboard运行通过调试模式运行6.使用SpringBootActuato
【2024年华为OD机试】 (C卷,200分)- 亲子游戏(JavaScript&Java & Python&C/C++)
妄北y
算法汇集笔记总结(保姆级) 华为od c语言 游戏 java javascript 矩阵
一、问题描述宝宝和妈妈的糖果游戏问题题目描述在一个N×N的二维矩阵中,宝宝和妈妈分别用抽签决定自己的初始位置。每个格子可能有不同的糖果数量,同时部分格子有障碍物,妈妈需要遵循以下规则:妈妈必须在最短的时间内到达宝宝的位置(每单位时间只能移动一步)。妈妈沿路可以拾取格子上的糖果,糖果数量会累加。妈妈不能走障碍物的格子,只能上下左右移动。如果妈妈无法到达宝宝,则输出-1。输入格式:第一行输入为N,表示
html+Canvas+js 实现 图片的剪裁效果
慕容屠苏
大前端爬坑之路
html+Canvas实现图片的剪裁效果开发过程中我们上传图片的时候,有时需要保证图片尺寸的统一,以避免以固定尺寸显示图片时会出现拉伸问题。这是就需要在上传之前对图片进行裁剪后再上传图片。我们裁剪图片将会用到canvas:canvas是HTML5中的一个新元素,这个元素可以通过JavaScript用来绘制图形。例如可以用它来画图、合成图象、做一些动画等。通常呢,我们在canvas上画图的方法是使用
Java学习之ArrayList原理剖析
李楠琳
Java java arraylist
ArrayList底层是基于数组实现的,其封装的各种方法:Add、remove、get、set等,其本质就是对数组的基本操作。publicclassArrayListextendsAbstractListimplementsList,RandomAccess,Cloneable,java.io.SerializableArrayList继承自AbstractList类,实现了RandomAcces
利用Java爬虫按图搜索1688商品(拍立淘):实战案例指南
数据小小爬虫
java 爬虫 图搜索算法
在电商领域,按图搜索功能(如1688的“拍立淘”)为用户提供了更直观、便捷的购物体验。通过上传图片,用户可以快速找到与图片相似的商品。本文将详细介绍如何利用Java爬虫技术实现按图搜索1688商品,并获取其详情数据。一、为什么选择Java爬虫?Java作为一种广泛使用的编程语言,以其稳健性和跨平台性在企业级应用中占据重要地位。通过Java,我们可以编写爬虫程序,模拟浏览器行为,从网页中提取所需的数
Java 集合框架:ArrayList 的介绍、使用、原理与源码解析
栗筝i
栗筝i 的 Java 技术栈(付费部分) # Java 基础 - 专栏 栗筝i 的 Java 技术栈 Java 基础 Java 集合 ArrayList Java
大家好,我是栗筝i,这篇文章是我的“栗筝i的Java技术栈”专栏的第013篇文章,在“栗筝i的Java技术栈”这个专栏中我会持续为大家更新Java技术相关全套技术栈内容。专栏的主要目标是已经有一定Java开发经验,并希望进一步完善自己对整个Java技术体系来充实自己的技术栈的同学。与此同时,本专栏的所有文章,也都会准备充足的代码示例和完善的知识点梳理,因此也十分适合零基础的小白和要准备工作面试的同
JAVA/RUST/C#/Kotlin 各语言语法糖及特性对比表
zimoyin
java rust c#
各语言语法糖及特性对比表声明:所有数据均由AI整合生成语法糖/特性说明GoC#KotlinJava(版本及备注)Rust局部方法嵌套方法,可访问外部局部变量✅✅✅✅✅(可用闭包,但用fn定义的内嵌函数不能捕获环境)lock语句简化线程同步(Java中对应使用synchronized)❌✅❌(使用synchronized)✅(使用synchronized)❌(采用Mutex+RAII模式实现同步)u
java dom4j解析XSD文件
yemao100
java
1.用DOM4J解析XSD文件,找出XSD文件中所有的element,type的定义,(xsd文件有4W多行),最终找出的结果是element和type定义有6000多个,2.递归找出指定type所用到的所有关联的元素,其中有用到XPATH来查找结点根据type在xsd文件中查找,找到有type和element是自定义的就递归下去继续往下找,直到找到最后所有的type和element都是XSD自带
Java常见排序算法及代码实现
芥子沫
排序算法 java 算法
1、选择排序算法选择排序(SelectionSort)是一种简单直观的排序算法,它的工作原理是每次从未排序部分选择最小(或最大)的元素,将其放到已排序部分的末尾。2、冒泡排序算法冒泡排序(BubbleSort)是一种简单的排序算法,它重复地遍历要排序的数列,一次比较两个元素,如果它们的顺序错误就把它们交换过来。遍历数列的工作是重复进行的,直到没有再需要交换的元素为止。3、插入排序算法插入排序的基本
工行银企直联(dom4j+java无中间件版)
gudongFox
后端 java http
工行银企直联(dom4j无中间件版)最近,接手了工行银企直联的任务,在网上找了很多,发现能一次说清的文章很少,此篇文章专为第一次接触银企直联的同学准备。1、准备包:dom4j(自行百度,如果这一步都不知道怎么做,接下来的过程也就别看了)2、逻辑3、Http的Post方法//工行支付前对报文签名publicstaticStringsignICBC(Stringurl,Stringparam){Pri
javascript中Object对象常用方法总结
善良的农场主
javascript
1.Object.createObject.create的语法:Object.create(proto,[propertiesObject]),创建一个对象,新创建的对象的prototype指向第一个参数,第二个参数是为新创建对象添加属性proto是原型对象propertiesObject是属性的配置在详解Object.create之前,我们先回忆一下常用的创建对象的方法:1.{},2.newOb
java xsd解析_java dom4j解析XSD文件
洋溢最棒
java xsd解析
1.用DOM4J解析XSD文件,找出XSD文件中所有的element,type的定义,(xsd文件有4W多行),最终找出的结果是element和type定义有6000多个,2.递归找出指定type所用到的所有关联的元素,其中有用到XPATH来查找结点根据type在xsd文件中查找,找到有type和element是自定义的就递归下去继续往下找,直到找到最后所有的type和element都是XSD自带
13天Java进阶笔记-day13-XML和Dom4j、装饰模式、工厂模式、commons-io工具包
madao10086+
Java学习笔记 xml java jar
第一章Dom4jDom4j获取Document对象和根元素dom4j属于第三方技术,必须导入该框架!!dom4j安装步骤:去dom4j官网下载dom4j的框架:都是一些jar包。把dom4j的核心jar包导入到当前项目中去。在项目中创建一个文件夹:lib将dom4j-2.1.1.jar文件复制到lib文件夹在jar文件上点右键,选择AddasLibrary->点击OK在类中导包使用Java提供了C
android 安装第三方apk自动赋予运行时权限
通信侠
android_system android
摘要:行业机使用场景点击运行时权限很麻烦,而随着android的演进,对于权限的管控越发严格。故本文通过对系统的修改实现第三方app在运行时直接获取全部权限。通过属性ro.perms.force_grant控制功能开关。Index:frameworks/base/services/core/java/com/android/server/pm/permission/Permission.java=
JavaScript中常用函数方法(对象篇)
YF-SOD
JavaScript Object.create Object() isPrototypeOf getPrototypeOF js中对象的常见方法
目录Object(obj)object对象调用的方法object.hasOwnProperty(prop)object.isPrototypeOf(obj)object.propertyIsEnumerable(prop)Object上定义的静态方法Object.create(obj,propertiesObject)参数示例Object.getPrototypeOf(obj)Object.fre
蓝桥杯 Java B 组之排序算法(冒泡、选择、插入排序)
计算机小白一个
排序算法 算法 数据结构
Day1:排序算法(冒泡、选择、插入排序)一、排序算法基础排序算法是蓝桥杯JavaB组的高频考点,主要考察:手写基础排序算法(冒泡、选择、插入)理解时间复杂度使用排序解决实际问题(如求TopK)二、三大基础排序算法1.冒泡排序(BubbleSort)思想:两两比较相邻元素较大的元素向后移动最多执行n-1轮每一轮都把最大数“冒泡”到最后原理:冒泡排序是一种简单的排序算法。它重复地走访过要排序的数列,
怎么样才能成为专业的程序员?
cocos2d-x小菜
编程 PHP
如何要想成为一名专业的程序员?仅仅会写代码是不够的。从团队合作去解决问题到版本控制,你还得具备其他关键技能的工具包。当我们询问相关的专业开发人员,那些必备的关键技能都是什么的时候,下面是我们了解到的情况。
关于如何学习代码,各种声音很多,然后很多人就被误导为成为专业开发人员懂得一门编程语言就够了?!呵呵,就像其他工作一样,光会一个技能那是远远不够的。如果你想要成为
java web开发 高并发处理
BreakingBad
java Web 并发 开发 处理 高
java处理高并发高负载类网站中数据库的设计方法(java教程,java处理大量数据,java高负载数据) 一:高并发高负载类网站关注点之数据库 没错,首先是数据库,这是大多数应用所面临的首个SPOF。尤其是Web2.0的应用,数据库的响应是首先要解决的。 一般来说MySQL是最常用的,可能最初是一个mysql主机,当数据增加到100万以上,那么,MySQL的效能急剧下降。常用的优化措施是M-S(
mysql批量更新
ekian
mysql
mysql更新优化:
一版的更新的话都是采用update set的方式,但是如果需要批量更新的话,只能for循环的执行更新。或者采用executeBatch的方式,执行更新。无论哪种方式,性能都不见得多好。
三千多条的更新,需要3分多钟。
查询了批量更新的优化,有说replace into的方式,即:
replace into tableName(id,status) values
微软BI(3)
18289753290
微软BI SSIS
1)
Q:该列违反了完整性约束错误;已获得 OLE DB 记录。源:“Microsoft SQL Server Native Client 11.0” Hresult: 0x80004005 说明:“不能将值 NULL 插入列 'FZCHID',表 'JRB_EnterpriseCredit.dbo.QYFZCH';列不允许有 Null 值。INSERT 失败。”。
A:一般这类问题的存在是
Java中的List
g21121
java
List是一个有序的 collection(也称为序列)。此接口的用户可以对列表中每个元素的插入位置进行精确地控制。用户可以根据元素的整数索引(在列表中的位置)访问元素,并搜索列表中的元素。
与 set 不同,列表通常允许重复
读书笔记
永夜-极光
读书笔记
1. K是一家加工厂,需要采购原材料,有A,B,C,D 4家供应商,其中A给出的价格最低,性价比最高,那么假如你是这家企业的采购经理,你会如何决策?
传统决策: A:100%订单 B,C,D:0%
&nbs
centos 安装 Codeblocks
随便小屋
codeblocks
1.安装gcc,需要c和c++两部分,默认安装下,CentOS不安装编译器的,在终端输入以下命令即可yum install gccyum install gcc-c++
2.安装gtk2-devel,因为默认已经安装了正式产品需要的支持库,但是没有安装开发所需要的文档.yum install gtk2*
3. 安装wxGTK
yum search w
23种设计模式的形象比喻
aijuans
设计模式
1、ABSTRACT FACTORY—追MM少不了请吃饭了,麦当劳的鸡翅和肯德基的鸡翅都是MM爱吃的东西,虽然口味有所不同,但不管你带MM去麦当劳或肯德基,只管向服务员说“来四个鸡翅”就行了。麦当劳和肯德基就是生产鸡翅的Factory 工厂模式:客户类和工厂类分开。消费者任何时候需要某种产品,只需向工厂请求即可。消费者无须修改就可以接纳新产品。缺点是当产品修改时,工厂类也要做相应的修改。如:
开发管理 CheckLists
aoyouzi
开发管理 CheckLists
开发管理 CheckLists(23) -使项目组度过完整的生命周期
开发管理 CheckLists(22) -组织项目资源
开发管理 CheckLists(21) -控制项目的范围开发管理 CheckLists(20) -项目利益相关者责任开发管理 CheckLists(19) -选择合适的团队成员开发管理 CheckLists(18) -敏捷开发 Scrum Master 工作开发管理 C
js实现切换
百合不是茶
JavaScript 栏目切换
js主要功能之一就是实现页面的特效,窗体的切换可以减少页面的大小,被门户网站大量应用思路:
1,先将要显示的设置为display:bisible 否则设为none
2,设置栏目的id ,js获取栏目的id,如果id为Null就设置为显示
3,判断js获取的id名字;再设置是否显示
代码实现:
html代码:
<di
周鸿祎在360新员工入职培训上的讲话
bijian1013
感悟 项目管理 人生 职场
这篇文章也是最近偶尔看到的,考虑到原博客发布者可能将其删除等原因,也更方便个人查找,特将原文拷贝再发布的。“学东西是为自己的,不要整天以混的姿态来跟公司博弈,就算是混,我觉得你要是能在混的时间里,收获一些别的有利于人生发展的东西,也是不错的,看你怎么把握了”,看了之后,对这句话记忆犹新。 &
前端Web开发的页面效果
Bill_chen
html Web Microsoft
1.IE6下png图片的透明显示:
<img src="图片地址" border="0" style="Filter.Alpha(Opacity)=数值(100),style=数值(3)"/>
或在<head></head>间加一段JS代码让透明png图片正常显示。
2.<li>标
【JVM五】老年代垃圾回收:并发标记清理GC(CMS GC)
bit1129
垃圾回收
CMS概述
并发标记清理垃圾回收(Concurrent Mark and Sweep GC)算法的主要目标是在GC过程中,减少暂停用户线程的次数以及在不得不暂停用户线程的请夸功能,尽可能短的暂停用户线程的时间。这对于交互式应用,比如web应用来说,是非常重要的。
CMS垃圾回收针对新生代和老年代采用不同的策略。相比同吞吐量垃圾回收,它要复杂的多。吞吐量垃圾回收在执
Struts2技术总结
白糖_
struts2
必备jar文件
早在struts2.0.*的时候,struts2的必备jar包需要如下几个:
commons-logging-*.jar Apache旗下commons项目的log日志包
freemarker-*.jar
Jquery easyui layout应用注意事项
bozch
jquery 浏览器 easyui layout
在jquery easyui中提供了easyui-layout布局,他的布局比较局限,类似java中GUI的border布局。下面对其使用注意事项作简要介绍:
如果在现有的工程中前台界面均应用了jquery easyui,那么在布局的时候最好应用jquery eaysui的layout布局,否则在表单页面(编辑、查看、添加等等)在不同的浏览器会出
java-拷贝特殊链表:有一个特殊的链表,其中每个节点不但有指向下一个节点的指针pNext,还有一个指向链表中任意节点的指针pRand,如何拷贝这个特殊链表?
bylijinnan
java
public class CopySpecialLinkedList {
/**
* 题目:有一个特殊的链表,其中每个节点不但有指向下一个节点的指针pNext,还有一个指向链表中任意节点的指针pRand,如何拷贝这个特殊链表?
拷贝pNext指针非常容易,所以题目的难点是如何拷贝pRand指针。
假设原来链表为A1 -> A2 ->... -> An,新拷贝
color
Chen.H
JavaScript html css
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <HTML> <HEAD>&nbs
[信息与战争]移动通讯与网络
comsci
网络
两个坚持:手机的电池必须可以取下来
光纤不能够入户,只能够到楼宇
建议大家找这本书看看:<&
oracle flashback query(闪回查询)
daizj
oracle flashback query flashback table
在Oracle 10g中,Flash back家族分为以下成员:
Flashback Database
Flashback Drop
Flashback Table
Flashback Query(分Flashback Query,Flashback Version Query,Flashback Transaction Query)
下面介绍一下Flashback Drop 和Flas
zeus持久层DAO单元测试
deng520159
单元测试
zeus代码测试正紧张进行中,但由于工作比较忙,但速度比较慢.现在已经完成读写分离单元测试了,现在把几种情况单元测试的例子发出来,希望有人能进出意见,让它走下去.
本文是zeus的dao单元测试:
1.单元测试直接上代码
package com.dengliang.zeus.webdemo.test;
import org.junit.Test;
import o
C语言学习三printf函数和scanf函数学习
dcj3sjt126com
c printf scanf language
printf函数
/*
2013年3月10日20:42:32
地点:北京潘家园
功能:
目的:
测试%x %X %#x %#X的用法
*/
# include <stdio.h>
int main(void)
{
printf("哈哈!\n"); // \n表示换行
int i = 10;
printf
那你为什么小时候不好好读书?
dcj3sjt126com
life
dady, 我今天捡到了十块钱, 不过我还给那个人了
good girl! 那个人有没有和你讲thank you啊
没有啦....他拉我的耳朵我才把钱还给他的, 他哪里会和我讲thank you
爸爸, 如果地上有一张5块一张10块你拿哪一张呢....
当然是拿十块的咯...
爸爸你很笨的, 你不会两张都拿
爸爸为什么上个月那个人来跟你讨钱, 你告诉他没
iptables开放端口
Fanyucai
linux iptables 端口
1,找到配置文件
vi /etc/sysconfig/iptables
2,添加端口开放,增加一行,开放18081端口
-A INPUT -m state --state NEW -m tcp -p tcp --dport 18081 -j ACCEPT
3,保存
ESC
:wq!
4,重启服务
service iptables
Ehcache(05)——缓存的查询
234390216
排序 ehcache 统计 query
缓存的查询
目录
1. 使Cache可查询
1.1 基于Xml配置
1.2 基于代码的配置
2 指定可搜索的属性
2.1 可查询属性类型
2.2 &
通过hashset找到数组中重复的元素
jackyrong
hashset
如何在hashset中快速找到重复的元素呢?方法很多,下面是其中一个办法:
int[] array = {1,1,2,3,4,5,6,7,8,8};
Set<Integer> set = new HashSet<Integer>();
for(int i = 0
使用ajax和window.history.pushState无刷新改变页面内容和地址栏URL
lanrikey
history
后退时关闭当前页面
<script type="text/javascript">
jQuery(document).ready(function ($) {
if (window.history && window.history.pushState) {
应用程序的通信成本
netkiller.github.com
虚拟机 应用服务器 陈景峰 netkiller neo
应用程序的通信成本
什么是通信
一个程序中两个以上功能相互传递信号或数据叫做通信。
什么是成本
这是是指时间成本与空间成本。 时间就是传递数据所花费的时间。空间是指传递过程耗费容量大小。
都有哪些通信方式
全局变量
线程间通信
共享内存
共享文件
管道
Socket
硬件(串口,USB) 等等
全局变量
全局变量是成本最低通信方法,通过设置
一维数组与二维数组的声明与定义
恋洁e生
二维数组 一维数组 定义 声明 初始化
/** * */ package test20111005; /** * @author FlyingFire * @date:2011-11-18 上午04:33:36 * @author :代码整理 * @introduce :一维数组与二维数组的初始化 *summary: */ public c
Spring Mybatis独立事务配置
toknowme
mybatis
在项目中有很多地方会使用到独立事务,下面以获取主键为例
(1)修改配置文件spring-mybatis.xml <!-- 开启事务支持 --> <tx:annotation-driven transaction-manager="transactionManager" /> &n
更新Anadroid SDK Tooks之后,Eclipse提示No update were found
xp9802
eclipse
使用Android SDK Manager 更新了Anadroid SDK Tooks 之后,
打开eclipse提示 This Android SDK requires Android Developer Toolkit version 23.0.0 or above, 点击Check for Updates
检测一会后提示 No update were found