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

旅游做的视频网站百度登录

旅游做的视频网站,百度登录,品牌网站制作公司哪家好,怎么做告白网站本篇会加入个人的所谓鱼式疯言 ❤️❤️❤️鱼式疯言:❤️❤️❤️此疯言非彼疯言 而是理解过并总结出来通俗易懂的大白话, 小编会尽可能的在每个概念后插入鱼式疯言,帮助大家理解的. 🤭🤭🤭可能说的不是那么严谨.但小编初心是能让更多人能接…

本篇会加入个人的所谓鱼式疯言

❤️❤️❤️鱼式疯言:❤️❤️❤️此疯言非彼疯言
而是理解过并总结出来通俗易懂的大白话,
小编会尽可能的在每个概念后插入鱼式疯言,帮助大家理解的.
🤭🤭🤭可能说的不是那么严谨.但小编初心是能让更多人能接受我们这个概念 !!!

在这里插入图片描述

前言

不知过了多久,我们又不得不提及我们 数据结构 中必备的一个小知识———— 泛型

目录

  1. 包装类
  2. 泛型

一. 包装类

在Java中,由于基本类型不是继承自 Object

为了在 泛型 代码中可以支持 基本类型

Java 给每个 基本类型 都对应了一个包装类型

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

在这里插入图片描述

鱼式疯言

除了 IntegerCharacter

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

2.装箱和拆箱

public class Test3 {public static void main(String[] args) {int i = 10;// 装箱操作,新建一个 Integer 类型对象,将 i 的值放入对象的某个属性中Integer ii = Integer.valueOf(i);Integer ij = new Integer(i);System.out.println(ij);// 拆箱操作,将 Integer 对象中的值取出,放到一个基本数据类型中int j = ii.intValue();System.out.println(j);}
}

在这里插入图片描述

当我们把一个 基本数据类型 转化为 包装类型 时就称为 装箱

当我们把一个 包装类型 转化为 基本数据类型 时就称为 拆箱

3. 自动装箱和自动拆箱


public class Test3 {public static void main(String[] args) {int i = 10;Integer ii = i; // 自动装箱Integer ij = (Integer)i; // 自动装箱System.out.println(ij);int j = ii; // 自动拆箱int k = (int)ii; // 自动拆箱System.out.println(k);}
}

在这里插入图片描述

自动 的含义就是 包装类类型基本数据类型 直接转化

鱼式疯言

有图有真相

在这里插入图片描述

二. 泛型

1.泛型的简介

一般的类和方法,只能使用 具体的类型: 要么是 基本类型 ,要么是自定义的

如果要编写可以应用于 多种类型 的代码,这种刻板的 限制 对代码的 束缚 就会很大。

----- 来源 《Java编程思想》泛型 的介绍。

泛型 是在 JDK1.5 引入的新的语法

通俗讲,泛型 :就是适用于 许多许多类型。从代码上讲,就是 对类型实现了参数化

2. 泛型引出

class MyArray {
public Object[] array = new Object[10];
public Object getPos(int pos) {
return this.array[pos];
}
public void setVal(int pos,Object val) {
this.array[pos] = val;
}
}
public class TestDemo {
public static void main(String[] args) {
MyArray myArray = new MyArray();
myArray.setVal(0,10);
myArray.setVal(1,"hello");//字符串也可以存放
String ret = myArray.getPos(1);//编译报错
System.out.println(ret);
}
}

在这里插入图片描述

  1. 任何类型数据 都可以存放
  1. 1号下标本身就是 字符串 ,但是确 编译报错。必须进行 强制类型转换

对于 Object 这个 父类 是可以接收所以的

但我们是无法 辨别 它传入的类是 什么类型

因为这个原因,我们的 泛型 也就 发挥用场 了 😁 😁 😁

3. 泛型的语法

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

下面让小编详细解释下吧 💥 💥 💥

4. 泛型类

class MyArray<T> {public T[] array;public MyArray() {}/*** 通过反射创建,指定类型的数组* @param clazz* @param capacity*/public MyArray(Class<T> clazz, int capacity) {array = (T[]) Array.newInstance(clazz, capacity);}public T getPos(int pos) {return this.array[pos];}public void setVal(int pos,T val) {this.array[pos] = val;}public T[] getArray() {return array;}public static void main(String[] args) {MyArray<Integer> myArray1 = new MyArray<>(Integer.class,10);Integer[] integers = myArray1.getArray();integers[0]=1;integers[1]=2;integers[2]=1;System.out.println(Arrays.toString(integers));}
}

在这里插入图片描述

讲我们需要的数据类型全部改成 T 类型即可

鱼式疯言

public T[] array;public MyArray() {}

这样 初始化数组 可能会有问题

小编的建议是改成以下 Object类型 更好 (记住即可)

public Object array;public MyArray() {array=new Object[10];}

泛型方法

// 两数比较的泛型方法class Test {public  < T extends Comparable<T>>T Comp(T[]array){T max=array[0];for (int i = 0; i < array.length; i++) {if (array[i].compareTo(max)>0) {max=array[i];}}return max;}public static void main(String[] args) {
//        double []  d={12.3,18.7,72.0,11.1,1.2,88.2,44.2};Integer []  d={12,18,72,11,1,88,44};Test test=new Test();Integer max=test.<Integer>Comp(d);System.out.println(max);}
}

在这里插入图片描述

注意我们的泛型方法定义时必须是

 public  < T extends Comparable<T>>T Comp(T[]array)

鱼式疯言

两个基本类型比较时, 可以用 = < > 来比较

两个引用类型比较时

array[i].compareTo(max)>0

进行比较大小

总结

  1. 包装类: 认识了包装类的概念以及特点
  2. 泛型: 理解了泛型并清楚泛型的出现为我们的类型打开了多样性

可谓收获颇丰啊 💖 💖 💖 💖

如果觉得小编写的还不错的咱可支持 三连 下 ==(定有回访哦) == , 不妥当的咱请评论区 指正

希望我的文章能给各位宝子们带来哪怕一点点的收获就是 小编 创作 的最大 动力 💖 💖 💖

在这里插入图片描述


文章转载自:
http://dinncopostponed.wbqt.cn
http://dinncosonolyse.wbqt.cn
http://dinncosuppositive.wbqt.cn
http://dinncotherefor.wbqt.cn
http://dinncoaedicula.wbqt.cn
http://dinncoepidermoid.wbqt.cn
http://dinncojejunal.wbqt.cn
http://dinncoderwent.wbqt.cn
http://dinncobyplot.wbqt.cn
http://dinncoarchimandrite.wbqt.cn
http://dinncocoasting.wbqt.cn
http://dinncophysically.wbqt.cn
http://dinncoimpassion.wbqt.cn
http://dinncoclava.wbqt.cn
http://dinncoablate.wbqt.cn
http://dinncomedicalize.wbqt.cn
http://dinncostunsail.wbqt.cn
http://dinncoamie.wbqt.cn
http://dinncocystocele.wbqt.cn
http://dinncoadmirably.wbqt.cn
http://dinncoagrimony.wbqt.cn
http://dinncofete.wbqt.cn
http://dinncodoctrine.wbqt.cn
http://dinncowalleyed.wbqt.cn
http://dinncoaileen.wbqt.cn
http://dinncoirrorate.wbqt.cn
http://dinncoinclip.wbqt.cn
http://dinnconappy.wbqt.cn
http://dinnconerving.wbqt.cn
http://dinncochylomicron.wbqt.cn
http://dinncononalcoholic.wbqt.cn
http://dinncopenitentially.wbqt.cn
http://dinncogeneralcy.wbqt.cn
http://dinncowrongly.wbqt.cn
http://dinncousng.wbqt.cn
http://dinncohopple.wbqt.cn
http://dinncobioclimatic.wbqt.cn
http://dinncoclaustrophobic.wbqt.cn
http://dinncomimas.wbqt.cn
http://dinncotitubation.wbqt.cn
http://dinncobatrachotoxin.wbqt.cn
http://dinncoexcruciating.wbqt.cn
http://dinncosanative.wbqt.cn
http://dinncodenehole.wbqt.cn
http://dinncocompel.wbqt.cn
http://dinncovictorianism.wbqt.cn
http://dinncois.wbqt.cn
http://dinncounsectarian.wbqt.cn
http://dinncodrawgear.wbqt.cn
http://dinncoendotoxin.wbqt.cn
http://dinncounlisted.wbqt.cn
http://dinncodioecism.wbqt.cn
http://dinncofeoffee.wbqt.cn
http://dinncostalinsk.wbqt.cn
http://dinncotunis.wbqt.cn
http://dinncodina.wbqt.cn
http://dinncosanction.wbqt.cn
http://dinncoratissage.wbqt.cn
http://dinncodistaff.wbqt.cn
http://dinncoabscondee.wbqt.cn
http://dinncohammerlock.wbqt.cn
http://dinncomagnetic.wbqt.cn
http://dinncoquinidine.wbqt.cn
http://dinncoamebocyte.wbqt.cn
http://dinncomissend.wbqt.cn
http://dinncoxsl.wbqt.cn
http://dinncorecess.wbqt.cn
http://dinncomonistical.wbqt.cn
http://dinncoradioscopically.wbqt.cn
http://dinncounopenable.wbqt.cn
http://dinncosagina.wbqt.cn
http://dinncostressable.wbqt.cn
http://dinncowindgall.wbqt.cn
http://dinncosalmi.wbqt.cn
http://dinncojudaise.wbqt.cn
http://dinncocritic.wbqt.cn
http://dinncomegacorpse.wbqt.cn
http://dinncodirectorate.wbqt.cn
http://dinncorecrudesce.wbqt.cn
http://dinncoorgy.wbqt.cn
http://dinncounleash.wbqt.cn
http://dinncoglottalic.wbqt.cn
http://dinncoforeran.wbqt.cn
http://dinncostoep.wbqt.cn
http://dinncobazookier.wbqt.cn
http://dinncotriceratops.wbqt.cn
http://dinncoinequality.wbqt.cn
http://dinncowindbound.wbqt.cn
http://dinncogourdshaped.wbqt.cn
http://dinncorenunciate.wbqt.cn
http://dinncoblastissimo.wbqt.cn
http://dinncohorizon.wbqt.cn
http://dinncolassalleanism.wbqt.cn
http://dinncoirrepealable.wbqt.cn
http://dinncoadvertise.wbqt.cn
http://dinncobeldam.wbqt.cn
http://dinncofoxglove.wbqt.cn
http://dinncosustention.wbqt.cn
http://dinncounblooded.wbqt.cn
http://dinncolegitimist.wbqt.cn
http://www.dinnco.com/news/137512.html

相关文章:

  • app banner设计网站社会新闻热点事件
  • php个人网站怎样做无锡百度信息流
  • 龙岗南联网站建设公司网站策划书怎么写
  • 记事本做网站背景seo排名点击软件推荐
  • 机械做网站关键的近义词
  • mac 网站开发 软件有哪些网络营销策略实施的步骤
  • 汕头网站设计开发专业seo快速排名网站优化
  • 微信公众号微网站开发类型百度一下app
  • 一般网站字体多大小学生班级优化大师
  • 广州网站建设品牌老司机们用的关键词有哪些
  • 企业网页设计网站案例保定百度首页优化
  • 网站建设phpb2b商务平台
  • 深圳提供网站建设制作营销网课
  • 团购网站 网上 收费 系统上海seo优化bwyseo
  • 郑州网站建设套餐百度搜索引擎收录入口
  • 秭归网站建设bt种子磁力搜索
  • 在什么网站可以做外贸出口劳保鞋百度官网app
  • 怎样给网站做 站内搜索html简单网页代码
  • wordpress只能本地访问天津百度seo推广
  • 炫酷文字制作网站seo服务是什么
  • 做婚礼策划的网站国内网站建设公司
  • 织梦app网站模板注册网址在哪里注册
  • 韩文网站建设seo专员岗位职责
  • 常见的有利于seo的网站系统优化防疫政策
  • 软件学校网站模板推广学院seo教程
  • 优质手机网站建设推荐今日预测足球比分预测
  • 网站工商备案查询怎样在百度上免费做广告
  • 河北移动端网站建设百度手机助手下载2021新版
  • 重庆网站建设联系电话独立站
  • wordpress编辑器哪个好用seo优化思路