---恢复内容开始---

1数组.有序的同类型的集合。

2.string :字符串类型:其实就是一个字符数组。添加了private final,所以string是一个不可以变的字符串。

String.charAt(index):或者字符数组的元素

equals():比较是每个字符是否相等。即比较的是内容。

字符串常用方法和源码;

3.stringbuilder

可扩容的字符串。也就是自动实现了字符数组的扩大。一般是两倍。

4,arraylist。数组列表,封装了数组。

5.多维数组:

虽然数组定义时候要声明长度,但对于多维数组,声明第一维就可以了。(多维数组看成是在一维数组中加入其他维度的数组)

int[][] a=new int[3][];
a[0]=new int[3];
a[1]=new int[5];
....
a[0][0]=1;
a[0][1]=3;
....
//二维数组长度可以随意,

6,system.arraycopy(Object src, int srcPos, Object dest, int destPos, int length)

@param src the source array.
* @param srcPos starting position in the source array.
* @param dest the destination array.
* @param destPos starting position in the destination data.
* @param length the number of array elements to be copied.

将一个数组复制到另一个数组中

arrays类中copyOf方法也是调用。  

 public static char[] copyOf(char[] original, int newLength) {
char[] copy = new char[newLength];
System.arraycopy(original, 0, copy, 0,
Math.min(original.length, newLength));//这样做有一定的容错能力,不用考虑越界了
return copy;
}

8.Arrays类提供一些处理数组的方法。(常用的排序和查找方法)

sort(基本类型数组):排序。

binarySeach(数组,元素)。二分法查找。必须先排序。

toStirng(数组对象):数组元素的打印效果

fill(int[] a, int fromIndex, int toIndex, int val):将数组索引从...到...替换成。

9.如果是对象数组排序。对象需要实现comparable接口的compareTo方法。

10冒泡法:

int[] a = {...};
for (int i = 0; i < a.length - 1; i++) {
for (int j = 0; j < a.length - 1 - i; j++) {
if (a[j] > a[j + 1]) {
int t = a[j];
a[j] = a[j + 1];
a[j + 1] = t;
}
}
}
System.out.println(Arrays.toString(a));

  

基础笔记3(一)(String StringBuilder StringBuffer 数组)的更多相关文章

  1. java基础解析系列(一)---String、StringBuffer、StringBuilder

    java基础解析系列(一)---String.StringBuffer.StringBuilder 前言:本系列的主题是平时容易疏忽的知识点,只有基础扎实,在编码的时候才能更注重规范和性能,在出现bu ...

  2. 深入源码剖析String,StringBuilder,StringBuffer

    [String,StringBuffer,StringBulider] 深入源码剖析String,StringBuilder,StringBuffer [作者:高瑞林] [博客地址]http://ww ...

  3. difference among String,StringBuilder,StringBuffer

    difference among String,StringBuilder,StringBuffer String常用构造函数 String(byte[] bytes) String(byte[] b ...

  4. JDK源码分析系列---String,StringBuilder,StringBuffer

    JDK源码分析系列---String,StringBuilder,StringBuffer 1.String public final class String implements java.io. ...

  5. java中String StringBuilder StringBuffer比较和效率(性能)测试

    string stringbuilder stringbuffer三者的区别 从JDK源码看,String.StringBuilder.StringBuffer都是存放在char[] 数组字符串. 简 ...

  6. String, StringBuilder, StringBuffer问题

    1. 区别 String为字符串常量,而StringBuilder和StringBuffer都是字符串变量,其中StringBuilder线程非安全,StringBuffer线程安全. 每次对 Str ...

  7. String StringBuilder StringBuffer区别

    String StringBuilder StringBuffer String类是final类,不可以被继承,且它的成员方法也是final方法,当一个字符串对象进行操作操作时,任何的改变不会影响到这 ...

  8. java - day009 - 基础API,object,String, StringBuilder/StringBuffer, 正则表达式

    API java.lang.object object 所有类的顶层父类 一个类如果不继承其他类,默认继承object.    toString() 获得一个对象的字符串表示     可以重写     ...

  9. Java笔记(二十一)……String与StringBuffer

    String类 String类是一个特殊的类,叫做只读类,一旦创建了对象,便不可被改变,同样"abc"既为一个常量,也为一个对象,也是不可以改变的 String s1 = &quo ...

随机推荐

  1. zepto源码--核心方法8(管理包装集)--学习笔记

    继续包装集过滤的相关函数的介绍,今天介绍与父元素相关的函数,parent, parents, closest, offsetParent parent 获取对象集合中每个元素的直接父元素. 与上篇文章 ...

  2. 临时存存储页面上的数据---js中的cookie

    实现的效果: 当点击某个按钮的时候,实现点击A的同时,弹出B的注册div,使填写在B信息数据保存下来,点击B的确定按钮,B消失,A的图标往后移动一格,原来的位置为图标C,点击C可以弹出来一个链接的页面 ...

  3. oracle:case when 语句的区间用法

    在练习case when 语句时,碰到一个例子,结果答案根本就不对,语法就通不过,开始想着是不是case 只能是一个固定的取值,毕竟例子内给的都是case是个固定的值,后来网上查了好久才发现还有区间的 ...

  4. (copy) DBAN vs nwipe

    source: https://sourceforge.net/p/dban/discussion/208932/thread/cb591b59/ Question:Trouble in runnin ...

  5. alibaba的FastJson(高性能JSON开发包),fastjson 使用demo

    这是关于FastJson的一个使用Demo,在Java环境下验证的 class User{ private int id; private String name; public int getId( ...

  6. LaTeX插入图表方法 Lists of tables and figures

    Lists of tables and figures A list of the tables and figures keep the information organized and prov ...

  7. Ant执行Jmeter工程模版

    <?xml version="1.0" encoding="GB2312"?><project name="ant-jmeter-t ...

  8. C# 窗体

    窗体的事件:删除事件:先将事件页面里面的挂好的事件删除,再删后台代码里面的事件 Panel是一个容器 1.Label -- 文本显示工具Text:显示的文字取值.赋值:lable1.Text 2.Te ...

  9. System.arraycopy

    ref : http://blog.csdn.net/jaycee110905/article/details/45228249

  10. 【转】PowerShell入门(一):PowerShell能干什么?

    转至:http://www.cnblogs.com/ceachy/archive/2013/01/30/WhatCanPowerShellDo.html PowerShell能干什么呢?就像序言中提到 ...