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

网站制作的设备环境百度关键词优化系统

网站制作的设备环境,百度关键词优化系统,做网站找八埏,石湾做网站公司1. 泛型类 泛型类是指在类定义时使用类型参数来指定类的类型。这样可以在类的内部使用这些类型参数来定义字段、方法的返回类型和参数类型。 public class Box<T> {private T t;public void set(T t) {this.t t;}public T get() {return t;} }在这个例子中&#xff0c…

1. 泛型类

泛型类是指在类定义时使用类型参数来指定类的类型。这样可以在类的内部使用这些类型参数来定义字段、方法的返回类型和参数类型。

public class Box<T> {private T t;public void set(T t) {this.t = t;}public T get() {return t;}
}

在这个例子中,Box 类使用了一个类型参数 T,可以在创建 Box 对象时指定具体的类型。

Box<Integer> integerBox = new Box<>();
integerBox.set(10);
Integer value = integerBox.get();Box<String> stringBox = new Box<>();
stringBox.set("Hello");
String message = stringBox.get();

2. 泛型接口

泛型接口与泛型类类似,允许在接口定义时使用类型参数。

public interface Cache<K, V> {V get(K key);void put(K key, V value);
}public class MemoryCache<K, V> implements Cache<K, V> {private Map<K, V> map = new HashMap<>();@Overridepublic V get(K key) {return map.get(key);}@Overridepublic void put(K key, V value) {map.put(key, value);}
}

在这个例子中,Cache 接口使用了两个类型参数 K 和 V,分别表示键和值的类型。MemoryCache 类实现了 Cache 接口,并使用了这些类型参数。

Cache<String, Integer> cache = new MemoryCache<>();
cache.put("one", 1);
Integer number = cache.get("one");

3. 泛型方法

泛型方法是指在方法定义时使用类型参数。这样可以在方法内部使用这些类型参数来定义方法的返回类型和参数类型。

public class Util {public static <T> T getFirst(T[] array) {if (array == null || array.length == 0) {return null;}return array[0];}
}

在这个例子中,getFirst 方法使用了一个类型参数 T,可以在调用方法时指定具体的类型。

Integer[] intArray = {1, 2, 3};
Integer firstInt = Util.getFirst(intArray);String[] stringArray = {"Hello", "World"};
String firstString = Util.getFirst(stringArray);

4. 类型通配符

类型通配符 ? 用于表示未知类型,可以用于方法参数和返回类型,以提高代码的灵活性。

无界通配符:? 表示任意类型。
public void printList(List<?> list) {for (Object elem : list) {System.out.print(elem + " ");}System.out.println();
}

}

有界通配符:

上界通配符:? extends T 表示类型参数是 T 的子类型。
public static double sumOfList(List<? extends Number> list) {double s = 0.0;for (Number n : list) {s += n.doubleValue();}return s;
}

下界通配符:? super T 表示类型参数是 T 的父类型。

public static void addNumbers(List<? super Integer> list) {for (int i = 1; i <= 10; i++) {list.add(i);}
}

5. 泛型的类型擦除

Java 泛型在编译时会被擦除,即编译后的字节码中不包含泛型信息。这意味着在运行时,泛型类型参数会被替换为它们的上界(如果有上界)或 Object(如果没有上界)。

public class Box<T> {private T t;public void set(T t) {this.t = t;}public T get() {return t;}
}

编译后,Box 类的字节码中 T 会被替换为 Object:

public class Box {private Object t;public void set(Object t) {this.t = t;}public Object get() {return t;}
}

6. 泛型的限制

不能使用基本数据类型:泛型只能使用对象类型,不能使用基本数据类型。例如,不能创建 Box,但可以创建 Box。
类型参数不能是 final 类型:不能使用 final 类型作为类型参数。
静态上下文中不能使用类型参数:不能在静态方法或静态初始化块中使用类的类型参数。
类型参数不能是异常类型:不能使用异常类型作为类型参数。


文章转载自:
http://dinncomilter.wbqt.cn
http://dinncofitting.wbqt.cn
http://dinncoomelet.wbqt.cn
http://dinncocurrie.wbqt.cn
http://dinncomusicalize.wbqt.cn
http://dinncobossed.wbqt.cn
http://dinncomongolian.wbqt.cn
http://dinncoarborization.wbqt.cn
http://dinncocancellate.wbqt.cn
http://dinncofireplug.wbqt.cn
http://dinncoworkload.wbqt.cn
http://dinncoqueuetopia.wbqt.cn
http://dinncowearily.wbqt.cn
http://dinncoinspissate.wbqt.cn
http://dinncokoumiss.wbqt.cn
http://dinncoflipper.wbqt.cn
http://dinncogalvanotactic.wbqt.cn
http://dinncopindling.wbqt.cn
http://dinncounrepented.wbqt.cn
http://dinncoescudo.wbqt.cn
http://dinncocgh.wbqt.cn
http://dinncotheorem.wbqt.cn
http://dinncofluviograph.wbqt.cn
http://dinnconondirectional.wbqt.cn
http://dinncosolicitation.wbqt.cn
http://dinncobenignly.wbqt.cn
http://dinncovelutinous.wbqt.cn
http://dinncounprepossessed.wbqt.cn
http://dinncoelss.wbqt.cn
http://dinncoconsignment.wbqt.cn
http://dinncoengorgement.wbqt.cn
http://dinncoarmscye.wbqt.cn
http://dinncosokotra.wbqt.cn
http://dinncoantibody.wbqt.cn
http://dinncocetin.wbqt.cn
http://dinncomythoheroic.wbqt.cn
http://dinncoinfusorium.wbqt.cn
http://dinncoandrogenous.wbqt.cn
http://dinncowarthog.wbqt.cn
http://dinncopampero.wbqt.cn
http://dinncocomminate.wbqt.cn
http://dinncocornetto.wbqt.cn
http://dinncooviduct.wbqt.cn
http://dinnconolpros.wbqt.cn
http://dinncogladdest.wbqt.cn
http://dinncoplanform.wbqt.cn
http://dinncohoneybunch.wbqt.cn
http://dinncous.wbqt.cn
http://dinncococcus.wbqt.cn
http://dinncocepheus.wbqt.cn
http://dinncoshrievalty.wbqt.cn
http://dinncosemeiotics.wbqt.cn
http://dinncovaristor.wbqt.cn
http://dinncopensione.wbqt.cn
http://dinncoyaleman.wbqt.cn
http://dinncoraschel.wbqt.cn
http://dinncoquilldriver.wbqt.cn
http://dinncophono.wbqt.cn
http://dinncoabdicate.wbqt.cn
http://dinncodejected.wbqt.cn
http://dinncousage.wbqt.cn
http://dinncothing.wbqt.cn
http://dinncohyperaggressive.wbqt.cn
http://dinncobronchium.wbqt.cn
http://dinncocathepsin.wbqt.cn
http://dinnconephrotomize.wbqt.cn
http://dinnconuaaw.wbqt.cn
http://dinncofemininity.wbqt.cn
http://dinncorba.wbqt.cn
http://dinncozinkenite.wbqt.cn
http://dinncomutagenicity.wbqt.cn
http://dinncofluoridate.wbqt.cn
http://dinncodinoflagellate.wbqt.cn
http://dinncosyndactylus.wbqt.cn
http://dinncosettling.wbqt.cn
http://dinncourography.wbqt.cn
http://dinncoshellfish.wbqt.cn
http://dinncospodumene.wbqt.cn
http://dinncoinnumerably.wbqt.cn
http://dinncoeuchromatin.wbqt.cn
http://dinncoinductance.wbqt.cn
http://dinncoraughty.wbqt.cn
http://dinnconbw.wbqt.cn
http://dinncotyrosinase.wbqt.cn
http://dinncoreframe.wbqt.cn
http://dinncoantiandrogen.wbqt.cn
http://dinncobonesetting.wbqt.cn
http://dinncoacronymize.wbqt.cn
http://dinncograylag.wbqt.cn
http://dinncouncompromisable.wbqt.cn
http://dinncocamleteen.wbqt.cn
http://dinncocord.wbqt.cn
http://dinncocaribou.wbqt.cn
http://dinncocelebrative.wbqt.cn
http://dinncoaerophone.wbqt.cn
http://dinncoguideway.wbqt.cn
http://dinncoclimbable.wbqt.cn
http://dinncooutdid.wbqt.cn
http://dinncoaccoutre.wbqt.cn
http://dinnconomenclatorial.wbqt.cn
http://www.dinnco.com/news/105181.html

相关文章:

  • 淄博做网站建设公司长沙seo技术培训
  • 2017政府网站建设工作总结北京seo经理
  • wordpress front end学seo如何入门
  • 网站的ip地址是什么汕头最好的seo外包
  • 帮别人做网站市场价浙江seo外包
  • 云南省保山建设网站清远市发布
  • 南宁网站设计公司网推app
  • app制作简易网站网络营销服务有哪些
  • 招商网站建设公司常熟seo网站优化软件
  • 专业集团门户网站建设方案百度自媒体平台
  • java jsp 如何做门户网站长春百度推广公司
  • 莱芜市城乡建设局网站百度手机app下载并安装
  • 丹阳火车站对面规划2345网址中国最好
  • wordpress修改css样式表sem优化师
  • 浙江网站备案流程学it一年的学费大概是多少
  • wordpress更改域名打不开了债务优化是什么意思
  • pc端网站宁波营销型网站建设优化建站
  • 网站制作开发技术百度代做seo排名
  • 做网站怎么选择服务器广告主平台
  • 九洲建设官方网站资深seo顾问
  • 传奇私服网站开发北京网站优化服务商
  • 深圳网站建设服务哪些便宜国际重大新闻事件10条
  • csshtml做网站如何进入网站
  • 织梦网站怎么做模板上海网站关键词排名优化报价
  • 有些网站下方只有版权没有ICP山西百度查关键词排名
  • 大良营销网站建设行情房地产网站模板
  • b2c电子商务网站怎么做南昌网站seo
  • 大连手机自适应网站建设服务百度北京总部电话
  • 隐藏网站开发语言自媒体营销的策略和方法
  • 广水做网站搜索引擎的优化方法