随笔分类 -  Java学习

上一页 1 ··· 4 5 6 7 8
摘要:public class ListDemo { public static void main(String[] args) { //示例1: int[] arr = {1,2,3,4,5}; for (int i : arr){ System.out.println(i); } System.ou 阅读全文
posted @ 2020-04-08 09:51 硬盘红了 阅读(142) 评论(0) 推荐(0)
摘要:案例需求: 一个集合,里面有三个元素:list.add("hello"); list.add("world"); list.add("java"); 遍历集合,如果有”world“这个元素,我们就添加一个”javaee“元素进去。 代码如下: public class list_03 { publi 阅读全文
posted @ 2020-04-07 22:25 硬盘红了 阅读(420) 评论(0) 推荐(0)
摘要:public class ListDemo { public static void main(String[] args) { //创建List集合对象 List<Student> list = new ArrayList<Student>(); //创建学生对象 Student s1 = new 阅读全文
posted @ 2020-04-07 21:18 硬盘红了 阅读(637) 评论(0) 推荐(0)
摘要:集合元素框架 public class ListDemo02 { public static void main(String[] args) { //创建集合对象 List<String> list = new ArrayList<String>(); //添加元素 list.add("hello 阅读全文
posted @ 2020-04-07 21:07 硬盘红了 阅读(237) 评论(0) 推荐(0)
摘要:public class CollectionDemo { public static void main(String[] args) { //创建collection集合对象 Collection<Student> c = new ArrayList<Student>(); //创建学生对象 S 阅读全文
posted @ 2020-04-06 19:28 硬盘红了 阅读(286) 评论(0) 推荐(0)
摘要:Iterator : 迭代器,集合的专用遍历方式Iterator <E> iterator() : 返回此集合中元素的迭代器,通过集合的iterator()方法得到迭代器是通过集合的iterator()方法得到的,所以我们说它是依赖于集合而存在的Iterator中的常用方法 E next() : 返 阅读全文
posted @ 2020-04-06 17:06 硬盘红了 阅读(133) 评论(0) 推荐(0)
摘要:boolean add(E e) import java.util.ArrayList; import java.util.Collection; public class CollectionDemo_02 { public static void main(String[] args) { // 阅读全文
posted @ 2020-04-06 15:40 硬盘红了 阅读(180) 评论(0) 推荐(0)
摘要:/* 自定义异常:ScoreException */ public class ScoreException extends Exception { //无参构造 public ScoreException(){} //带参构造 public ScoreException(String messag 阅读全文
posted @ 2020-04-06 14:23 硬盘红了 阅读(148) 评论(0) 推荐(0)
摘要:使用switch-case语句的练习 阅读全文
posted @ 2019-03-24 21:04 硬盘红了 阅读(445) 评论(0) 推荐(0)
摘要:1 import java.util.Scanner; 2 3 public class Main { 4 5 public static void main(String[] args) { 6 // TODO Auto-generated method stub 7 Scanner in = new Scanner(System.in... 阅读全文
posted @ 2019-03-24 20:33 硬盘红了 阅读(670) 评论(0) 推荐(0)
摘要:1 import java.util.Scanner; 2 3 public class Main { 4 5 public static void main(String[] args) { 6 // TODO Auto-generated method stub 7 int f; 8 int c; 9 ... 阅读全文
posted @ 2019-03-24 17:55 硬盘红了 阅读(279) 评论(0) 推荐(0)

上一页 1 ··· 4 5 6 7 8