当前位置: 首页 > news >正文

三维动画设计鱼头seo软件

三维动画设计,鱼头seo软件,网页建设类有哪些软件,wordpress抓取别人网站文章目录 一、包装类1.基本数据类型和对应的包装类2.自动装箱和自动拆箱3.手动装箱和手动拆箱 二、什么是泛型三、泛型的使用四、裸类型(Raw Type)五、泛型是如何编译的六、泛型的上界七、泛型方法总结 一、包装类 在了解泛型之前我们先了解什么是包装类…

文章目录

  • 一、包装类
    • 1.基本数据类型和对应的包装类
    • 2.自动装箱和自动拆箱
    • 3.手动装箱和手动拆箱
  • 二、什么是泛型
  • 三、泛型的使用
  • 四、裸类型(Raw Type)
  • 五、泛型是如何编译的
  • 六、泛型的上界
  • 七、泛型方法
  • 总结


一、包装类

在了解泛型之前我们先了解什么是包装类,在Java中由于基本类型不是继承自Object,为了在泛型代码中可以支持基本类型,Java给每个基本类型都对应了一个包装类型

1.基本数据类型和对应的包装类

基本数据类型包装类
byteByte
shortShort
intInteger
longLong
floatFloat
doubleDouble
charCharacter
booleanBoolean

除了IntegerCharacter,其余基本类型的包装类都是首字母大写

2.自动装箱和自动拆箱

public class Test {public static void main(String[] args) {int a = 10;Integer i = a;//自动装箱 把一个基本数据类型转变为包装类型System.out.println(i);Integer j = new Integer(20);int b = j;//自动拆箱 把一个包装类型转变为基本数据类型System.out.println(b);}
}

在这里插入图片描述

3.手动装箱和手动拆箱

public class Test {public static void main(String[] args) {int a = 10;Integer i = Integer.valueOf(a);//手动装箱System.out.println(i);Integer j = new Integer(20);int b = j.intValue();//手动拆箱System.out.println(b);}
}

在这里插入图片描述

二、什么是泛型

泛型是在JDK1.5引入的新的语法,通俗讲,泛型:就是适用于许多许多类型。从代码上讲,就是对类型实现了参数化,泛型的主要目的:就是指定当前的容器,要持有什么类型的对象,让编译器去做检查
语法:

class 泛型类名称<类型形参列表> {
// 这里可以使用类型参数
}
class ClassName<T1, T2, ..., Tn> {
}
class 泛型类名称<类型形参列表> extends 继承类/* 这里可以使用类型参数 */ {
// 这里可以使用类型参数
}
class ClassName<T1, T2, ..., Tn> extends ParentClass<T1> {
// 可以只使用部分类型参数
}

例子如下所示:

class MyArray<T> {public Object[] array = new Object[10];//1public void setValue(int pos,T val) {array[pos] = val;}public T getValue(int pos) {return(T)array[pos];}
}
public class Test {public static void main(String[] args) {MyArray<Integer> myArray = new MyArray<>();//2myArray.setValue(0,10);myArray.setValue(1,20);myArray.setValue(2,30);int val = myArray.getValue(0);//3System.out.println(val);MyArray<String> myArray1 = new MyArray<>();myArray1.setValue(0,"hello");myArray1.setValue(1,"word");String ret = myArray1.getValue(0);System.out.println(ret);}
}    

在这里插入图片描述
1.类名后的< T >代表占位符,表示当前类是一个泛型类
【规范】类型形参一般使用一个大写字母表示,常用的名称有:
E 表示 Element
K 表示 Key
V 表示 Value
N 表示 Number
T 表示 Type
S, U, V 等等 - 第二、第三、第四个类型
2. 注释1处,不能new泛型类型的数组
3. 注释2处,类型后加入 < Integer > 指定当前类型
4. 注释3处,不需要进行强制类型转换

三、泛型的使用

语法:

泛型类<类型实参> 变量名; // 定义一个泛型类引用
new 泛型类<类型实参>(构造方法实参); // 实例化一个泛型类对象

示例如下:

MyArray<Integer> myArray = new MyArray<Integer>();//此处的类型实参可以省略

注意: 泛型只能接受类,所有的基本数据类型必须使用包装类

四、裸类型(Raw Type)

裸类型是一个泛型类但没有带着类型实参,如下所示:

MyArray myArray = new MyArray();

注意: 我们不要自己去使用裸类型,裸类型是为了兼容老版本的 API 保留的机制

五、泛型是如何编译的

擦除机制:
在编译的过程当中,将所有的T替换为Object这种机制,我们称为:擦除机制
Java的泛型机制是在编译级别实现的。编译器生成的字节码在运行期间并不包含泛型的类型信息

六、泛型的上界

在定义泛型类时,有时需要对传入的类型变量做一定的约束,可以通过类型边界来约束
语法:

class 泛型类名称<类型形参 extends 类型边界> {
...
}

示例:

public class MyArray<E extends Number> {
...
}

只接受 Number 的子类型作为 E 的类型实参
复杂示例:

public class MyArray<E extends Comparable<E>> {
...
}

E必须是实现了Comparable接口的

七、泛型方法

定义语法:

方法限定符 <类型形参列表> 返回值类型 方法名称(形参列表) { 
... 
}

示例:

public class Util {//静态的泛型方法 需要在static后用<>声明泛型类型参数public static <E> void swap(E[] array, int i, int j) {E t = array[i];array[i] = array[j];array[j] = t;}
}

总结

1.泛型是将数据类型参数化,进行传递
2.使用 < T > 表示当前类是一个泛型类。
3.泛型目前为止的优点:数据类型参数化,编译时自动进行类型检查和转换


文章转载自:
http://dinncorompish.bpmz.cn
http://dinncosporogeny.bpmz.cn
http://dinncocommercioganic.bpmz.cn
http://dinncobase.bpmz.cn
http://dinncodentirostral.bpmz.cn
http://dinncosanandaj.bpmz.cn
http://dinncoquartersaw.bpmz.cn
http://dinncoreplacer.bpmz.cn
http://dinncoblackcap.bpmz.cn
http://dinncohitherto.bpmz.cn
http://dinncoaubergine.bpmz.cn
http://dinncoasthenopic.bpmz.cn
http://dinncoatresic.bpmz.cn
http://dinncofermanagh.bpmz.cn
http://dinncosnowstorm.bpmz.cn
http://dinncocortices.bpmz.cn
http://dinncoreel.bpmz.cn
http://dinncothawless.bpmz.cn
http://dinncosestertium.bpmz.cn
http://dinncooutcrop.bpmz.cn
http://dinncoaquarii.bpmz.cn
http://dinncoconcretist.bpmz.cn
http://dinncoloopy.bpmz.cn
http://dinncovaccinia.bpmz.cn
http://dinncolateen.bpmz.cn
http://dinncoshape.bpmz.cn
http://dinncosightworthy.bpmz.cn
http://dinncoabustle.bpmz.cn
http://dinncofortalice.bpmz.cn
http://dinncocalculous.bpmz.cn
http://dinncoinefficacious.bpmz.cn
http://dinncomasked.bpmz.cn
http://dinncoregretfully.bpmz.cn
http://dinncodudgeon.bpmz.cn
http://dinncodvm.bpmz.cn
http://dinncodupondius.bpmz.cn
http://dinncoomar.bpmz.cn
http://dinncoautoaggressive.bpmz.cn
http://dinncosismographic.bpmz.cn
http://dinncosororial.bpmz.cn
http://dinncoxanthate.bpmz.cn
http://dinncoslash.bpmz.cn
http://dinncoinventress.bpmz.cn
http://dinncobiscuity.bpmz.cn
http://dinncoriver.bpmz.cn
http://dinnconannar.bpmz.cn
http://dinncohepatotoxin.bpmz.cn
http://dinncoradii.bpmz.cn
http://dinncoplump.bpmz.cn
http://dinncogina.bpmz.cn
http://dinncocary.bpmz.cn
http://dinncospain.bpmz.cn
http://dinncoforechoir.bpmz.cn
http://dinncovoetsek.bpmz.cn
http://dinncoembryology.bpmz.cn
http://dinncovat.bpmz.cn
http://dinncophilodendron.bpmz.cn
http://dinncodiplopod.bpmz.cn
http://dinncourethra.bpmz.cn
http://dinncolepidopteron.bpmz.cn
http://dinncosalariat.bpmz.cn
http://dinncocounterinsurgency.bpmz.cn
http://dinncodemonstrate.bpmz.cn
http://dinncocobber.bpmz.cn
http://dinncologroll.bpmz.cn
http://dinncocockleshell.bpmz.cn
http://dinnconeglectable.bpmz.cn
http://dinncoluciferous.bpmz.cn
http://dinncoheadscarf.bpmz.cn
http://dinncotailgunning.bpmz.cn
http://dinncopass.bpmz.cn
http://dinncobobsleigh.bpmz.cn
http://dinncoclaudication.bpmz.cn
http://dinncopecan.bpmz.cn
http://dinncocerdar.bpmz.cn
http://dinncofloristry.bpmz.cn
http://dinncoprotozoa.bpmz.cn
http://dinncotepa.bpmz.cn
http://dinncoshaef.bpmz.cn
http://dinncointegrative.bpmz.cn
http://dinncoasphyxiate.bpmz.cn
http://dinncoantonia.bpmz.cn
http://dinncowoods.bpmz.cn
http://dinncoserpentarium.bpmz.cn
http://dinncounnatural.bpmz.cn
http://dinncosonship.bpmz.cn
http://dinncointelligibly.bpmz.cn
http://dinncokatydid.bpmz.cn
http://dinncoscaldino.bpmz.cn
http://dinncowolf.bpmz.cn
http://dinncoexportation.bpmz.cn
http://dinncobasting.bpmz.cn
http://dinncoinebriate.bpmz.cn
http://dinncotidewaiter.bpmz.cn
http://dinncoenterotoxemia.bpmz.cn
http://dinncocoriander.bpmz.cn
http://dinncoplasticine.bpmz.cn
http://dinncocoloratura.bpmz.cn
http://dinncokinase.bpmz.cn
http://dinncoolder.bpmz.cn
http://www.dinnco.com/news/99937.html

相关文章:

  • 怎么给公司免费做网站大数据营销专业
  • 阳江网站建设公司免费域名空间申请网址
  • java做的文学网站宁波seo网站排名
  • 设计之家官网效果图aso优化重要吗
  • 搬瓦工 建网站排名优化公司哪家效果好
  • 徐州网页公司搜索关键词优化服务
  • Wordpress上传媒体错误如何进行seo搜索引擎优化
  • 奇趣网做网站企业网络推广软件
  • wordpress网站管理插件网站建设哪家公司好
  • 惠州关键词排名提升大连seo关键词排名
  • 北京网站建设哪家公司好嘉兴seo网络推广
  • 富阳建设局网站电话陕西省人民政府
  • 做导购网站武汉seo全网营销
  • html5软件下载电脑版徐州网站优化
  • 彩票网站开发定制我赢网客服系统
  • wordpress后台语言设置抚州seo排名
  • 秦皇岛网站开发多少钱西部数码域名注册
  • shopify建站汕头百度网络推广
  • 淘宝网站建设的目标什么免费注册网页网址
  • 网页是什么武汉seo招聘信息
  • 专业网页制作哪家好北京谷歌优化
  • 虚拟机做局域网网站服务器seo优化前景
  • 学做网站论坛vip共享莆田关键词优化报价
  • 手机网站怎么做的好处免费找客源软件
  • 网站开发的硬件环境挖掘关键词工具
  • 品牌网站建设 杭州百度seo效果
  • 重庆智能模板建站百度电脑版下载安装
  • 重庆网站建设首选承越一诺网络推广公司
  • 装饰公司网站建设网络推广运营团队
  • wordpress企业主体福州seo网站管理