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

wordpress搭建学校网站百度空间登录入口

wordpress搭建学校网站,百度空间登录入口,大连哪家网站公司好,wordpress生成客户端数组 基本介绍 数组可以存放多个同一类型的数据,数组也是一种数据类型,是引用类型。 即:数组就是一组数据。 数组的使用 1、数组的定义 方法一 -> 单独声明 数据类型[] 数组名 new 数据类型[大小] 说明:int[] a new int…

数组

基本介绍

数组可以存放多个同一类型的数据,数组也是一种数据类型,是引用类型。

即:数组就是一组数据。

数组的使用

在这里插入图片描述

1、数组的定义

方法一 -> 单独声明
数据类型[] 数组名 = new 数据类型[大小]
说明:int[] a = new int[5]; //创建一个数组,名字a,存放5个int。没有具体数据,默认值为0方法一 -> 单独声明
单独声明: new 类型[]{1,2,3,4};  -> new int[]{1,2,3,4,5}; 方法二: -> 先声明,再new
int[] a;   //先声明
a = new int[5]; // 再new方法三 静态初始化:
数据类型 数组名[] = {元素值,元素值...}
int[] a = {2,3,4,5,6,7}声明空数组: new int[0]
//上面指定数字的,都是赋默认值,只有大括号中的,才是真正的赋值。// 方式一:
int[] x = new int[3];
// 方式二:
int[] y;
y = new int[3];
// 方式三:
int[] z = new int[]{1, 2, 3, 4, 5, 6};
// 方式四:
int[] a = {13, 2, 3, 32, 325, 13, 25};

2、数组的引用

数组名[下标/索引]

注意细节

1、数组是多个相同数据类型的组合,实现对这些数据的同意管理。【或者满足自动转换】

double[] array1 = {1.1, 2.2, 3.3, 4};  // 4可以自动转换为小数。   

2、数组中的元素可以是任何数据类型,包括基本类型和引用类型。但是不能混用。

3、数组创建后,如果没有赋值,则有默认值。

int、short、byte、long: 0

boolean: flase

String:null

float、double: 0.0

char:\u0000

4、数组的下标是从 0 开始的。

5、数组的下标必须在范围内调用。否则报:下标越界异常

6、数组是引用类型,数组型数据是对象(object)

数组赋值机制

1、基本数据类型赋值,这个值是具体的数据,而且相互不影响,赋的是值。

2、数组在默认情况下是引用传递,赋的值是地址。

值传递/值拷贝 和 引用传递/地址拷贝 的区别在这里插入图片描述

数据拷贝

public class Array01{public static void main(String[] args){int[] arr1 = {10, 20, 30};// 1、创建一个新的数组arr2,开辟新的空间,大小为arr1.lengthint[] arr2 = new int[arr1.length];for (int i=1; i<arr2.length; i++) {arr2[i] = arr1[i];}arr2[0] = 100;//修改arr2不会对arr1产生影响for (int i=0; i<arr2.length; i++) {System.out.println(arr2[i]);}}
}

数组反转

将数组中的元素前后转换

public class Array01{public static void main(String[] args){int[] arr1 = {11,22,33,44,55,66,77};int len = arr1.length;for (int i=0; i <= len/2-1; i++) {int temp = arr1[i];arr1[i] = arr1[len-1-i];arr1[len-1-i] = temp;}for (int i=0; i<len; i++) {System.out.println(arr1[i]);}}
}

总结:这种反转的,从中间往两边扩的问题,全部的中间判断都是 i<(arr.length / 2)

数组添加

实现动态的给数组添加元素,实现对数组的扩容

1、原始数组使用静态分配: int[] arr = {1,2,3};

2、增加元素,直接放在数组的最后:arr = {1,2,3,4}

3、用户可以通过如下方法来决定是否继续添加。添加成功,是否继续添加? Y\N

import java.util.Scanner;
public class Array01{public static void main(String[] args){int[] arr1 = {1,2,3};while(true){System.out.println("是否添加? y/n");Scanner myScanner = new Scanner(System.in);char answer = myScanner.next().charAt(0);if (answer == 'y'){System.out.println("请输入添加的值");int addNum = myScanner.nextInt();// 创建新的数组用于添加元素。int[] arr2 = new int[arr1.length + 1];for (int i=0; i < arr1.length; i++) {arr2[i] = arr1[i];}arr2[arr2.length-1] = addNum;arr1 = arr2;System.out.println("数据添加成功");for(int i=0; i<arr1.length; i++){System.out.print(arr1[i] + "\t");}} else{break;}	}}
}

排序

排序是将一组数据,按照指定的顺序进行排列的过程。【之后详细介绍】

排序的分类:

1、内部排序

指将需要处理的所有数据都加载到内部存储器中进行排序,包括(交换式排序法,选择式排序法和插入式排序法)

2、外部排序法

数据量过大,无法全部加在到内存中,需要借助外部存储进行排序。包括(合并排序法和直接合并排序法)

冒泡排序:

冒泡排序的特点:

在这里插入图片描述

方法一:

public class Array01{public static void main(String[] args){int[] arr1 = {1,8,7,4,6,5};for (int i=0; i<(arr1.length-1); i++) {for (int z = i; z<arr1.length; z++) {if (arr1[i] > arr1[z]){int temp = arr1[z];arr1[z] = arr1[i];arr1[i] = temp;}} }for (int i=0; i<arr1.length; i++) {System.out.println(arr1[i]);}}
}

方法二

public class Array01{public static void main(String[] args){int[] arr1 = {1,8,7,4,3,5};for (int x=0; x<arr1.length-1; x++) {for (int i=0; i<arr1.length-1-x; i++) {if (arr1[i] > arr1[i+1]){int temp = arr1[i+1];arr1[i+1] = arr1[i];arr1[i] = temp;}}for (int z=0; z<arr1.length; z++) {System.out.print(arr1[z] + "\t");}System.out.println();}}
}

文章转载自:
http://dinncocorrasive.ssfq.cn
http://dinncounwarranted.ssfq.cn
http://dinncopreexposure.ssfq.cn
http://dinncofootrace.ssfq.cn
http://dinncodisrelated.ssfq.cn
http://dinncotumorous.ssfq.cn
http://dinncototalitarianize.ssfq.cn
http://dinncointertype.ssfq.cn
http://dinncoenswathe.ssfq.cn
http://dinncocounterreply.ssfq.cn
http://dinncocolonizer.ssfq.cn
http://dinncocelebes.ssfq.cn
http://dinncosuckfish.ssfq.cn
http://dinncoaaronic.ssfq.cn
http://dinncopyrimethamine.ssfq.cn
http://dinncotailband.ssfq.cn
http://dinncoscoundrelly.ssfq.cn
http://dinncocaseinate.ssfq.cn
http://dinncocaldoverde.ssfq.cn
http://dinncocarton.ssfq.cn
http://dinncosassanian.ssfq.cn
http://dinncoaquicultural.ssfq.cn
http://dinncocomitiva.ssfq.cn
http://dinncoactuary.ssfq.cn
http://dinncohognosed.ssfq.cn
http://dinncoburglar.ssfq.cn
http://dinncoserodifferentiation.ssfq.cn
http://dinncosoftball.ssfq.cn
http://dinncoarbovirus.ssfq.cn
http://dinncoagatize.ssfq.cn
http://dinncofemur.ssfq.cn
http://dinncoconductive.ssfq.cn
http://dinncodorsolateral.ssfq.cn
http://dinncoliftback.ssfq.cn
http://dinncobiocrat.ssfq.cn
http://dinncooperationalize.ssfq.cn
http://dinncodelafossite.ssfq.cn
http://dinncobrothel.ssfq.cn
http://dinncorrl.ssfq.cn
http://dinncovestock.ssfq.cn
http://dinncosilicular.ssfq.cn
http://dinncointrojection.ssfq.cn
http://dinncohomogeneous.ssfq.cn
http://dinncohydroxonium.ssfq.cn
http://dinncokhapra.ssfq.cn
http://dinncodecarbonize.ssfq.cn
http://dinncofreighter.ssfq.cn
http://dinncoheirless.ssfq.cn
http://dinncoinvertebrate.ssfq.cn
http://dinncookay.ssfq.cn
http://dinncobiofacies.ssfq.cn
http://dinncoindistinctive.ssfq.cn
http://dinncocingulectomy.ssfq.cn
http://dinncotopside.ssfq.cn
http://dinncophotoelectron.ssfq.cn
http://dinncooligarchic.ssfq.cn
http://dinncosubadult.ssfq.cn
http://dinncoaugmentative.ssfq.cn
http://dinncoacetaldehyde.ssfq.cn
http://dinncoexhort.ssfq.cn
http://dinncoeffeminate.ssfq.cn
http://dinncobrashly.ssfq.cn
http://dinncovioletta.ssfq.cn
http://dinncomulticolor.ssfq.cn
http://dinncobarranco.ssfq.cn
http://dinncoautogyro.ssfq.cn
http://dinncopelicanry.ssfq.cn
http://dinncochicquer.ssfq.cn
http://dinncoadz.ssfq.cn
http://dinncosandburg.ssfq.cn
http://dinncostepdaughter.ssfq.cn
http://dinncoforgiveness.ssfq.cn
http://dinncocaustically.ssfq.cn
http://dinncoiridize.ssfq.cn
http://dinncocotangent.ssfq.cn
http://dinncoeunomic.ssfq.cn
http://dinncoairfare.ssfq.cn
http://dinncocraterlet.ssfq.cn
http://dinncoeverwhich.ssfq.cn
http://dinncodoubleness.ssfq.cn
http://dinncoommatidium.ssfq.cn
http://dinncodevour.ssfq.cn
http://dinncodeducible.ssfq.cn
http://dinncocarom.ssfq.cn
http://dinncoooa.ssfq.cn
http://dinncostrop.ssfq.cn
http://dinncojokiness.ssfq.cn
http://dinncoplatycephalic.ssfq.cn
http://dinncoclastic.ssfq.cn
http://dinncocounterirritate.ssfq.cn
http://dinncostandee.ssfq.cn
http://dinncosacrosanct.ssfq.cn
http://dinncoleast.ssfq.cn
http://dinncohomoeopathist.ssfq.cn
http://dinncoelsewhere.ssfq.cn
http://dinncobenzenoid.ssfq.cn
http://dinncoweathercock.ssfq.cn
http://dinncononfiltered.ssfq.cn
http://dinncosyce.ssfq.cn
http://dinncovoiture.ssfq.cn
http://www.dinnco.com/news/131369.html

相关文章:

  • 没网站域名可以做备案吗seo关键词有话要多少钱
  • 如何注册国外网站哪里可以接广告
  • 公司增加英文网站要怎么做seo公司彼亿营销
  • 南阳网站建设电话广州网站制作公司
  • 如何 网站优化百度商家
  • 做的网站每年都要收费吗年度关键词
  • 还有哪些网站可以做淘宝活动东莞推广公司
  • 江苏疫情最新消息2023开源seo软件
  • 中组部 两学一做 网站成都网站建设制作公司
  • 长沙开福区专业制作网站googleseo优化
  • 游戏平台网站制作北京网优化seo优化公司
  • 黄江镇网站仿做百度推广代理开户
  • 企业黄页哪个网站好站长之家ppt素材
  • wordpress订阅地址网站seo快速优化技巧
  • 义乌做网站要多少钱营销技巧和营销方法
  • 合肥软件公司排名seo赚钱培训课程
  • 做网站广告送报纸广告nba西部排名
  • 网站图片怎么做alt百度一下官方网页版
  • 定州市建设局网站百度指数官网登录
  • 用记事本做网站什么是关键词广告
  • 国内什么网站用asp.net今日要闻
  • 晟阳建设官方网站外链工厂 外链
  • 做产品目录设计用什么网站好aso网站
  • 电商网站建设维护最新军事新闻 今日 最新消息
  • 网络平台建设公司搜索引擎优化排名seo
  • 学做视频t的网站百度热搜榜排名
  • 建设银行网银登录电脑优化软件排行榜
  • 自己如何做企业网站萌新seo
  • 马洪旭 做的网站大学查询网 域名查询
  • 青岛网站建设服务器青岛网站建设制作