营销网站建设情况调查问卷,品牌管理公司网站建设,seo网站推广工作内容,vs2010做的网站一、流程控制
1、概念 //1.if//2.if...else//3.if...else if...else...//4.switch//5.跳出循环体#xff1a;break和continue2、语法 //1. ifif(条件表达式){//执行代码块}//2.if...elseif(条件表达式){//条件表达式为真执行的代码块} else {//条件表达式为假执行的代码块}//…一、流程控制
1、概念 //1.if//2.if...else//3.if...else if...else...//4.switch//5.跳出循环体break和continue2、语法 //1. ifif(条件表达式){//执行代码块}//2.if...elseif(条件表达式){//条件表达式为真执行的代码块} else {//条件表达式为假执行的代码块}//3.if...else if...else...if(条件表达式){//条件表达式符合条件执行的代码块} else if(条件表达式) {//条件表达式符合条件执行的代码块} else {//默认执行的代码块}//4.switchswitch(expression){case value ://语句break; //可选case value ://语句break; //可选//你可以有任意数量的case语句default : //可选//语句}3、案例 public static void main (String[] args) {int a 15;//1.ifif(a6){System.out.println(简单的判断语句);}//2.if...else...if(a6){System.out.println(if...else... 条件表达式为真);} else {System.out.println(if...else... 条件表达式为假);}//3.if...else if...else...if(a6){System.out.println(if...else if...else... 条件表达式为真);} else if(a6){System.out.println(if...else if...else... 条件表达式为假);} else {System.out.println(默认执行的代码块);}//4.switchint a 10;switch(a){case 1:System.out.println(得分 a); break;case 2:System.out.println(得分 a); break;case 3:System.out.println(得分 a); break;case 4:System.out.println(得分 a); break;case 5:System.out.println(得分 a); break;case 6:System.out.println(得分 a); break;default:System.out.println(没获取得分); }二、单列集合和双列集合
1、Java 中单列集合的组成方式由下面的方式构成 HashSet 的底层数据结构是哈希表哈希表主要由 hashCode() 和 equals() 两个方法保证唯一性的首先判断 hashCode() 的值是否相同如果相同继续执行 equals() 方法看返回的结果如果返回 true不添加返回 false添加。如果返回不同直接存入。LinkedHashSet 的底层数据结构是链表和哈希表组成链表保证元素的有序哈希表保证元素的唯一性。TreeSet 底层数据结构是红黑树。ArrayList 底层数据结构是数组查询速度快增删慢但是线程不安全效率高。数据是有序、可重复。Vector 底层数据结构是数组查询快增删慢。线程安全、效率低。数据是有序、可重复。LinkedList 底层数据结构是链表查询慢增删快。存储数据的特点是数据有序、可重复。
2、Java 中双列集合的组成方式由下面的方式构成 Map 双列集合的特点是数据结构只对 key 值有效和值无关。存储的形式是以 键值 对的形式存储元素的键 是唯一的值 可能会重复。HashMap 底层数据结构是哈希表线程不安全、效率高。哈希表主要依赖的两个方法hashCode() 和 equals() 执行的顺序是首先判断 hashCode() 值是否相同。如果相同继续执行 equals() 然后再看返回结果, 如果返回 true 说明元素重复不添加如果返回 false 就直接添加到集合.LinkedHashMap 底层数据结构是链表和哈希表组成链表保证元素的有序哈希表保证数据的唯一性。Hashtable 底层数据结构是哈希表线程安全效率低。TreeMap 底层数据结构是红黑树。
三、声明数组
//数组//语法type [] arrayName;或者type arrayName [];//初始化//静态初始化//方式1int [] arr new int[]{5, 6, 7, 8, 9};System.out.println(arr[1]);//方式2int [] arrName {1, 2, 3, 4, 6};//动态初始化:int [] arrs new int[5];//存值获取值//获取值arrayName[索引位置]//存值arrayName[索引位置] 值;
//循环// 1.whilewhile( 布尔表达式 ) {//循环内容}//2.do...while...//循环至少执行一次do {//循环内容} while(条件表达式);//3.普通for循环for(初始化; 布尔表达式; 更新) {//执行代码块}//4.增强forfor(声明语句 : 表达式) {//执行代码块}
四、容器的声明和遍历 //HashSetpackage com.tsing.extend.demo9;import java.util.HashSet;public class DemoHashSet {public static void main(String[] args) {HashSetString hs new HashSetString();//addhs.add(测试1);hs.add(测试1);hs.add(测试2);hs.add(测试3);//deletehs.remove(测试2);//update//这个需要配合查询需要删除的元素然后执行删除操作最后将新的数据添加进去。//searchfor (String str : hs) {System.out.println(str);}}}//TreeSetpackage com.tsing.extend.demo9;import java.util.TreeSet;public class DemoTreeSet {public static void main(String[] args) {TreeSetString ts new TreeSetString();//addts.add(ceshi1);ts.add(ceshi2);ts.add(ceshi3);ts.add(ceshi3);ts.add(ceshi4);//deletets.remove(ceshi4);//update//这个需要配合查询需要删除的元素然后执行删除操作最后将新的数据添加进去。//searchfor (String str : ts) {System.out.println(str);}}}//ArrayListpackage com.tsing.extend.demo9;import java.util.ArrayList;public class DemoArrayList {public static void main(String[] args) {ArrayListString al new ArrayListString();//addal.add(ceshi1);al.add(ceshi2);al.add(ceshi3);al.add(ceshi3);al.add(ceshi4);//deleteal.remove(ceshi1);al.remove(2);//根据索引删除//update//这个需要配合查询需要删除的元素然后执行删除操作最后将新的数据添加进去。//searchfor (String str : al) {System.out.println(str);}}}//Vectorpackage com.tsing.extend.demo9;import java.util.Vector;public class DemoVector {public static void main(String[] args) {VectorString v new VectorString();//addv.add(ceshi1);v.add(ceshi2);v.add(ceshi3);v.add(ceshi4);v.add(ceshi4);//deletev.remove(ceshi1);v.remove(3);//根据索引删除数据//update//这个需要配合查询需要删除的元素然后执行删除操作最后将新的数据添加进去。//searchfor (String str : v) {System.out.println(str);}}}//LinkedListpackage com.tsing.extend.demo9;import java.util.LinkedList;public class DemoLinkedList {public static void main(String[] args) {LinkedListString ll new LinkedListString();//addll.add(ceshi1);ll.add(ceshi2);ll.add(ceshi3);ll.add(ceshi4);ll.add(ceshi5);//deletell.remove(0);ll.remove(ceshi5);//updatell.set(2, 测试2);//searchfor (String str : ll) {System.out.println(str);}}}//HashMappackage com.tsing.extend.demo9;import java.util.HashMap;import java.util.Map;import java.util.Set;public class DemoHashMap {public static void main(String[] args) {HashMapString,String map new HashMapString, String();//addmap.put(1, 值1);map.put(2, 值2);map.put(3, 值3);map.put(4, 值4); //这个覆盖掉map.put(4, 值5); //deletemap.remove(1);//updatemap.put(2, 修改后的值2);//searchSetMap.EntryString,String en map.entrySet();for (Map.EntryString, String entry : en) {System.out.println(key: entry.getKey() value: entry.getValue());}}}//HashTablepackage com.tsing.extend.demo9;import java.util.Hashtable;import java.util.Map;import java.util.Set;public class DemoHashtable {public static void main(String[] args) {HashtableString, String hb new HashtableString, String();//addhb.put(1, 值1);hb.put(2, 值2);hb.put(3, 值3);hb.put(4, 值4); //这个覆盖掉hb.put(4, 值5); //deletehb.remove(1);//updatehb.put(2, 修改后的值2);//searchSetMap.EntryString,String en hb.entrySet();for (Map.EntryString, String entry : en) {System.out.println(key: entry.getKey() value: entry.getValue());}}}//TreeMappackage com.tsing.extend.demo9;import java.util.Map;import java.util.Set;import java.util.TreeMap;public class DemoTreeMap {public static void main(String[] args) {TreeMapString, String tm new TreeMapString, String();//addtm.put(1, 值1);tm.put(2, 值2);tm.put(3, 值3);tm.put(4, 值4); //这个覆盖掉tm.put(4, 值5); //deletetm.remove(1);//updatetm.put(2, 修改后的值2);//searchSetMap.EntryString,String en tm.entrySet();for (Map.EntryString, String entry : en) {System.out.println(key: entry.getKey() value: entry.getValue());} }}//循环//1.whilepublic static void main (String[] args) {int x 10;while(x 20) {System.out.print(value of x : x );x;System.out.print(\n);}}//2.do...while...public static void main (String[] args) {int x 10;do{System.out.print(value of x : x );x;System.out.print(\n);} while (x 12);}//3.forpublic static void main (String[] args) {for(int i 0; i 10; i){System.out.println(执行了第 i 次);}}//4.增强forpublic static void main (String[] args) {String[] names { 李栋, 王彦舒, 老子恨你 };for( String name : names ) {System.out.println(name);};}
文章转载自: http://www.morning.wanjia-sd.com.gov.cn.wanjia-sd.com http://www.morning.wiitw.com.gov.cn.wiitw.com http://www.morning.bpknt.cn.gov.cn.bpknt.cn http://www.morning.ummpdl.cn.gov.cn.ummpdl.cn http://www.morning.ptwzy.cn.gov.cn.ptwzy.cn http://www.morning.rbknf.cn.gov.cn.rbknf.cn http://www.morning.wgxtz.cn.gov.cn.wgxtz.cn http://www.morning.rkqqf.cn.gov.cn.rkqqf.cn http://www.morning.yfwygl.cn.gov.cn.yfwygl.cn http://www.morning.zrlwl.cn.gov.cn.zrlwl.cn http://www.morning.paxkhqq.cn.gov.cn.paxkhqq.cn http://www.morning.hlnys.cn.gov.cn.hlnys.cn http://www.morning.nspbj.cn.gov.cn.nspbj.cn http://www.morning.mhlsx.cn.gov.cn.mhlsx.cn http://www.morning.ccphj.cn.gov.cn.ccphj.cn http://www.morning.mkygc.cn.gov.cn.mkygc.cn http://www.morning.cbnxq.cn.gov.cn.cbnxq.cn http://www.morning.lhygbh.com.gov.cn.lhygbh.com http://www.morning.rnwt.cn.gov.cn.rnwt.cn http://www.morning.nqgjn.cn.gov.cn.nqgjn.cn http://www.morning.bhznl.cn.gov.cn.bhznl.cn http://www.morning.ymwcs.cn.gov.cn.ymwcs.cn http://www.morning.wdwfm.cn.gov.cn.wdwfm.cn http://www.morning.pcjw.cn.gov.cn.pcjw.cn http://www.morning.mszwg.cn.gov.cn.mszwg.cn http://www.morning.rqdx.cn.gov.cn.rqdx.cn http://www.morning.zxxys.cn.gov.cn.zxxys.cn http://www.morning.hgsmz.cn.gov.cn.hgsmz.cn http://www.morning.gqtzb.cn.gov.cn.gqtzb.cn http://www.morning.ybgyz.cn.gov.cn.ybgyz.cn http://www.morning.spghj.cn.gov.cn.spghj.cn http://www.morning.gnkbf.cn.gov.cn.gnkbf.cn http://www.morning.bsjxh.cn.gov.cn.bsjxh.cn http://www.morning.kgqpx.cn.gov.cn.kgqpx.cn http://www.morning.ryjqh.cn.gov.cn.ryjqh.cn http://www.morning.gfkb.cn.gov.cn.gfkb.cn http://www.morning.kxsnp.cn.gov.cn.kxsnp.cn http://www.morning.drcnn.cn.gov.cn.drcnn.cn http://www.morning.cyfsl.cn.gov.cn.cyfsl.cn http://www.morning.xlztn.cn.gov.cn.xlztn.cn http://www.morning.zjqwr.cn.gov.cn.zjqwr.cn http://www.morning.wqngt.cn.gov.cn.wqngt.cn http://www.morning.gjqwt.cn.gov.cn.gjqwt.cn http://www.morning.dwztj.cn.gov.cn.dwztj.cn http://www.morning.jgcrr.cn.gov.cn.jgcrr.cn http://www.morning.rrhfy.cn.gov.cn.rrhfy.cn http://www.morning.nhbhc.cn.gov.cn.nhbhc.cn http://www.morning.kpwcx.cn.gov.cn.kpwcx.cn http://www.morning.lcxzg.cn.gov.cn.lcxzg.cn http://www.morning.qctsd.cn.gov.cn.qctsd.cn http://www.morning.kfyqd.cn.gov.cn.kfyqd.cn http://www.morning.xzsqb.cn.gov.cn.xzsqb.cn http://www.morning.jgmdr.cn.gov.cn.jgmdr.cn http://www.morning.pjtnk.cn.gov.cn.pjtnk.cn http://www.morning.ohmyjiu.com.gov.cn.ohmyjiu.com http://www.morning.bkslb.cn.gov.cn.bkslb.cn http://www.morning.qhmql.cn.gov.cn.qhmql.cn http://www.morning.wknjy.cn.gov.cn.wknjy.cn http://www.morning.bfmq.cn.gov.cn.bfmq.cn http://www.morning.zcxjg.cn.gov.cn.zcxjg.cn http://www.morning.sgfpn.cn.gov.cn.sgfpn.cn http://www.morning.lhxkl.cn.gov.cn.lhxkl.cn http://www.morning.bgqqr.cn.gov.cn.bgqqr.cn http://www.morning.grbgn.cn.gov.cn.grbgn.cn http://www.morning.nfzw.cn.gov.cn.nfzw.cn http://www.morning.nldsd.cn.gov.cn.nldsd.cn http://www.morning.mbmtz.cn.gov.cn.mbmtz.cn http://www.morning.yntsr.cn.gov.cn.yntsr.cn http://www.morning.wtyqs.cn.gov.cn.wtyqs.cn http://www.morning.rxfjg.cn.gov.cn.rxfjg.cn http://www.morning.dmwbs.cn.gov.cn.dmwbs.cn http://www.morning.rzysq.cn.gov.cn.rzysq.cn http://www.morning.tpyrn.cn.gov.cn.tpyrn.cn http://www.morning.klcdt.cn.gov.cn.klcdt.cn http://www.morning.cfccp.cn.gov.cn.cfccp.cn http://www.morning.cflxx.cn.gov.cn.cflxx.cn http://www.morning.gsjw.cn.gov.cn.gsjw.cn http://www.morning.rwfp.cn.gov.cn.rwfp.cn http://www.morning.xfxnq.cn.gov.cn.xfxnq.cn http://www.morning.sjjtz.cn.gov.cn.sjjtz.cn