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

笑话类网站用什么做开发一个app价目表

笑话类网站用什么做,开发一个app价目表,网站建设绩效考核方案,新疆生产建设兵团考试信息网站"我已不在地坛&#xff0c;地坛在我" —— 《想念地坛》 24.5.28 一、Collections集合工具类 1.概述:集合工具类 2.特点: a.构造私有 b.方法都是静态的 3.使用:类名直接调用 4.方法: static <T> boolean addAll(collection<? super T>c,T... el…

"我已不在地坛,地坛在我"

                         —— 《想念地坛》 24.5.28

一、Collections集合工具类

1.概述:集合工具类

2.特点:

        a.构造私有
        b.方法都是静态的

3.使用:类名直接调用

4.方法:

        static <T> boolean addAll(collection<? super T>c,T... elements) —> 批量添加元素

        static void shuffle(List<?> list) —> 将集合中的元素顺序打乱

        static <T> void sort(List<T> list) —> 将集合中的元素按照默认规则排序
        static <T> void sort(List<T> list,comparator<? super T> c) —> 将集合中的元素按照指定规则排序

5.Comparator比较器

a.方法:

        int compare(T ol,T o2)
                o1-o2 ->升序
                o2-o1 -> 降序    

package S84Collections;public class Person {private String name;private Integer age;public Person() {}public Person(Integer age, String name) {this.name = name;this.age = age;}public String getName() {return name;}public void setName(String name) {this.name = name;}public Integer getAge() {return age;}public void setAge(Integer age) {this.age = age;}@Overridepublic String toString() {return "Person{" +"name='" + name + '\'' +", age=" + age +'}';}
}
package S84Collections;import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;public class Demo233Collections2 {public static void main(String[] args) {ArrayList<Person> list = new ArrayList<>();list.add(new Person(18,"小明"));list.add(new Person(19,"小红"));list.add(new Person(17,"小刚"));Collections.sort(list, new Comparator<Person>() {@Overridepublic int compare(Person o1, Person o2) {// 按年龄排序return o1.getAge()-o2.getAge();}});}
}

compareTo提前定义好排序规则

package S84Collections;public class Student implements Comparable<Student>{private String name;private Integer score;public Student() {}public Student(String name, Integer score) {this.name = name;this.score = score;}public String getName() {return name;}public void setName(String name) {this.name = name;}public Integer getScore() {return score;}public void setScore(Integer score) {this.score = score;}@Overridepublic String toString() {return "Student{" +"name='" + name + '\'' +", score=" + score +'}';}@Overridepublic int compareTo(Student o) {return this.getScore()-o.getScore();}
}
package S84Collections;import java.util.ArrayList;
import java.util.Collections;public class Demo234ArraysAsList {public static void main(String[] args) {ArrayList<Student> list = new ArrayList<>();list.add(new Student("小明",100));list.add(new Student("小红",98));list.add(new Student("小刚",75));Collections.sort(list); // Student提前决定排序规则System.out.println(list);   // [Student{name='小刚', score=75}, Student{name='小红', score=98}, Student{name='小明', score=100}]}
}

6.Arrays中的静态方法:

        static <T> List<T> asList(T...a) —> 直接指定元素,转存到list集合

        public static void main(string[] args){

                List<string> list = Arrays.asList("张三","李四”,"王五”);

                System.out.printin(list):

        }

package S84Collections;import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.List;public class Demo235ArraysAsList {public static void main(String[] args) {// static <T> List<T> asList(T...a) —> 直接指定元素,转存到list集合中// public static void main(string[] args){//      List<string> list = Arrays.asList("张三","李四”,"王五”);//      System.out.printin(list):// }List<String> list = Arrays.asList("张三","李四","王五");System.out.println(list);}
}

二、泛型 E/T/V/R

1.为什么要使用泛型?

        ① 从使用层面上说:

                统一数据类型,防止将来的数据类型转换异常

        ② 从定义层面来看:

                定义带泛型的类、方法等,将来使用的时候给泛型确定什么类型,泛型就会变成什么类型,凡是涉及到泛型的都会变成确定的类型,代码更加灵活

import java.util.ArrayList;public class Demo236Genericity1 {public static void main(String[] args) {ArrayList<Object> list = new ArrayList<>();list.add("hello");list.add("world");list.add(1);list.add(2.5);list.add(true);// 获取元素中为String类型的字符串长度for (Object o : list) {String s = (String) o;System.out.println(s.length());}}
}

2.什么时候确定类型

        new对象的时候确定类型

3.含有泛型的类

package S85Genericity;import java.util.Arrays;public class MyArrayList <E>{// 定义一个数组,充当ArrayList底层的数组,长度直接规定为10Object[] obj = new Object[10];// 定义size,代表集合元素个数int size;// 定义一个add方法,参数类型需要和泛型类型保持一致,数据类型为E,变量名随意public boolean add(E e){obj[size] = e;size++;return true;}// 定义一个get方法。根据索引获取元素public E get(int index){return (E) obj[index];}@Overridepublic String toString() {return Arrays.toString(obj);}
}
package S85Genericity;public class Demo238Test {public static void main(String[] args) {MyArrayList<String> list = new MyArrayList<>();list.add("一切都会好的");list.add("我一直相信");System.out.println(list);   // 直接输出对象名,默认调用toString// [一切都会好的, 我一直相信, null, null, null, null, null, null, null, null]System.out.println("————————————————————————");MyArrayList<Integer> list1 = new MyArrayList<>();list1.add(1);list1.add(2);list1.add(3);System.out.println(list1);// [1, 2, 3, null, null, null, null, null, null, null]Integer ele = list1.get(1);System.out.println(ele);    // 2}
}

4.含有泛型的方法

① 格式:

        修饰符 <E> 返回值类型 方法名(E e)

② 什么时候确定类型

        调用的时候确定类型

③ 示例

import java.util.ArrayList;public class ListUtils {// 定义一个静态方法addAll,添加多个集合的元素// 可变参数: E...e 可变参类型// E是声明不是返回值类型,还要另外传参数类型public static <E> void addAll(ArrayList<E> list,E ...e){// 遍历数组for (E element : e) {list.add(element);}}
}
public class Demo238Test {public static void main(String[] args) {MyArrayList<String> list = new MyArrayList<>();list.add("一切都会好的");list.add("我一直相信");System.out.println(list);   // 直接输出对象名,默认调用toString// [一切都会好的, 我一直相信, null, null, null, null, null, null, null, null]System.out.println("————————————————————————");MyArrayList<Integer> list1 = new MyArrayList<>();list1.add(1);list1.add(2);list1.add(3);System.out.println(list1);// [1, 2, 3, null, null, null, null, null, null, null]Integer ele = list1.get(1);System.out.println(ele);    // 2}
}

5.含有泛型的接口

① 格式:

        public interface 接口名<E>{

        

        }

② 什么时候确定类型:

        a.在实现类的时候还没有确定类型,只能在new实现类的时候确定类型了 —> ArrayList

        b.在实现类的时候百接确定类型了 —> 比如Scanner

③ 示例

        接口

package S85Genericity;public interface MyList <E>{public boolean add(E e);
}
package S85Genericity;import java.util.Arrays;public class MyArrayList1<E> implements MyList<E>{// 定义一个数组,充当ArrayList底层的数组,长度直接规定为10Object[] obj = new Object[10];// 定义size,代表集合元素个数int size;// 定义一个add方法,参数类型需要和泛型类型保持一致,数据类型为E,变量名随意public boolean add(E e){obj[size] = e;size++;return true;}// 定义一个get方法。根据索引获取元素public E get(int index){return (E) obj[index];}@Overridepublic String toString() {return Arrays.toString(obj);}
}
package S85Genericity;public class Demo239MyListTest {public static void main(String[] args) {MyArrayList<String> list1 = new MyArrayList<>();list1.add("nov 新的");list1.add("port 站点");list1.add("trans 转变");list1.add("fer 拿");list1.add("cover 覆盖 表面");list1.add("fess 说 讲");list1.add("view 看作 视作");list1.add("mean 意思 包含");list1.add("con 一起");list1.add("age 年龄 年代 作名词");System.out.println(list1);System.out.println(list1.get(0));}
}

6.泛型的上限下限

        1.作用:可以规定泛型的范围

        2.上限:

                a.格式:<? extends 类型>
                b.含义:?只能接收extends后面的本类类型以及子类类型

        3.下限:

                a.格式:<? super 类型>
                b.含义:?只能接收super后面的本类类型以及父类类型

7.应用场景:

        1.如果我们在定义类,方法,接口的时候,如果类型不确定,我们可以考虑定义含有泛型的类、方法、接口

        2.如果类型不确定,但是能知道以后只能传递某个类的继承体系中的子类或者父类,就可以使用泛型的通配符

package S85Genericity;import java.util.ArrayList;
import java.util.Collection;/*Integer ——> number ——> objectString ——> Object*/
public class Demo240Genericity4 {public static void main(String[] args) {ArrayList<Integer> list1 = new ArrayList<>();ArrayList<String> list2 = new ArrayList<>();ArrayList<Number> list3 = new ArrayList<>();ArrayList<Object> list4 = new ArrayList<>();get1(list1);// get1(list2);  错误get1(list3);// get1(list4); wojA\System.out.println();// get2((list1)); 错误// get2(list2);get2(list3);get2(list4);}//    上限    ? 只能接受extends后面的本类类型以及子类类型public static void get1(Collection<? extends Number> collection){}//    下限    ? 只能接收super后面的技术类型以及父类类型public static void get2(Collection<? super Number> collection){}//    应用场景:
//1.如果我们在定义类,方法,接口的时候,如果类型不确定,我们可以考虑定义含有泛型的类,方法,接口
// 2.如果类型不确定,但是能知道以后只能传递某个类的继承体系中的子类或者父类,就可以使用泛型的通配符}

文章转载自:
http://apheliotropic.spfh.cn
http://rhinitis.spfh.cn
http://carnivore.spfh.cn
http://paceway.spfh.cn
http://prefabricate.spfh.cn
http://duettist.spfh.cn
http://inconnu.spfh.cn
http://declassee.spfh.cn
http://bulldagger.spfh.cn
http://animator.spfh.cn
http://parthenogenetic.spfh.cn
http://poppy.spfh.cn
http://disharmonic.spfh.cn
http://bustling.spfh.cn
http://packer.spfh.cn
http://pesach.spfh.cn
http://gabbroid.spfh.cn
http://moorwort.spfh.cn
http://nagging.spfh.cn
http://bawcock.spfh.cn
http://shirring.spfh.cn
http://stink.spfh.cn
http://resumption.spfh.cn
http://congratulant.spfh.cn
http://mistranslate.spfh.cn
http://shoes.spfh.cn
http://jetfoil.spfh.cn
http://glut.spfh.cn
http://bayonet.spfh.cn
http://carafe.spfh.cn
http://apportionment.spfh.cn
http://laminary.spfh.cn
http://discreet.spfh.cn
http://dextropropoxyphene.spfh.cn
http://paradrop.spfh.cn
http://corresponsive.spfh.cn
http://seconder.spfh.cn
http://hyetograph.spfh.cn
http://kofu.spfh.cn
http://southdown.spfh.cn
http://asynergia.spfh.cn
http://pacemaker.spfh.cn
http://shudder.spfh.cn
http://satisfying.spfh.cn
http://pollock.spfh.cn
http://heartstricken.spfh.cn
http://vicissitudinous.spfh.cn
http://celticist.spfh.cn
http://chariot.spfh.cn
http://serpasil.spfh.cn
http://econiche.spfh.cn
http://voluntarism.spfh.cn
http://contemptibly.spfh.cn
http://embodiment.spfh.cn
http://stillbirth.spfh.cn
http://deceased.spfh.cn
http://fthm.spfh.cn
http://sorbose.spfh.cn
http://shifting.spfh.cn
http://elbowy.spfh.cn
http://diastyle.spfh.cn
http://punctiform.spfh.cn
http://frisco.spfh.cn
http://atelic.spfh.cn
http://protoderm.spfh.cn
http://subarachnoid.spfh.cn
http://stepped.spfh.cn
http://irrigable.spfh.cn
http://meacock.spfh.cn
http://attitudinal.spfh.cn
http://exclusivism.spfh.cn
http://dickey.spfh.cn
http://palmitin.spfh.cn
http://ascender.spfh.cn
http://girly.spfh.cn
http://mizenyard.spfh.cn
http://keratitis.spfh.cn
http://knockdown.spfh.cn
http://beadroll.spfh.cn
http://jeerer.spfh.cn
http://quatrefoil.spfh.cn
http://typesetting.spfh.cn
http://lookee.spfh.cn
http://nondiabetic.spfh.cn
http://unbundling.spfh.cn
http://yirr.spfh.cn
http://computus.spfh.cn
http://gallopade.spfh.cn
http://trihydric.spfh.cn
http://cephalization.spfh.cn
http://receptorology.spfh.cn
http://defraud.spfh.cn
http://kudos.spfh.cn
http://diplodocus.spfh.cn
http://numlock.spfh.cn
http://consenescence.spfh.cn
http://forgot.spfh.cn
http://exophagy.spfh.cn
http://deliberately.spfh.cn
http://seconde.spfh.cn
http://www.15wanjia.com/news/93600.html

相关文章:

  • 360免费建站连接怎么做游戏推广员
  • 微信电商平台有哪些seol英文啥意思
  • web网站开发培训学校做网站需要准备什么
  • 看广告赚钱怀化网站seo
  • 网站优化及推广方案成人再就业培训班
  • 佛山市住房和城乡建设局网站网页模板免费下载网站
  • 卖高仿名牌手表网站长沙靠谱seo优化价格
  • 什么网站可以做论坛app软文类型
  • 网站建设纳入本单位日常性工作大数据营销名词解释
  • 资讯网站策划怎么写安卓优化大师官网下载
  • 旅游门户网站源码怎么做的微信卖货小程序怎么做
  • 好看的个人网站主页腾讯搜索引擎入口
  • 衡水做wap网站的公司需要优化的地方
  • 个人网站 免费注册教育培训机构需要什么条件
  • wap建站程序网易企业邮箱
  • 龙岗网站建设服务杭州排名推广
  • 石家庄新华区网站建设青海seo关键词排名优化工具
  • 程序员做的网站别人用于诈骗厦门百度推广开户
  • 罗湖商城网站建设哪家公司便宜点关键词优化好
  • 专业企专业企业网站设计拼多多关键词排名查询软件
  • 福田做网站哪家专业流量点击推广平台
  • 科技公司 网站模板发稿软文公司
  • 做彩票网站代理赚钱吗手机关键词排名优化
  • 网站建设客户管理系统搜索百度指数
  • 做营销网站建设价格免费推广自己的网站
  • 网站建设 商城百度推广怎么收费标准案例
  • 自己做的网站怎么改背景图sem管理工具
  • 钢琴室内设计效果图win优化大师怎么样
  • 北京金企鹅网站建设方案泰安seo网络公司
  • 做跨境电商靠谱吗南京seo网络优化公司