package changjiandeotherclass;
public class Arrays {
public static void main(String[] args0){
Integer ip=1000;
System.out.println(ip);
/*Integer liang=null;
Integer i3=liang+ip;
System.out.println(i3);*/
/*int[] arr={89,59,52,2,74,25,200,33,66};
System.out.println(Integer.toBinaryString(10));
System.out.println(Integer.MAX_VALUE);
System.out.println(Integer.MIN_VALUE);
Integer sb =new Integer(123);
String i=sb.toString();
System.out.println(i);
String s="123456";
Integer.parseInt(s);
System.out.println(s);*/
}
}
package changjiandeotherclass;
import java.util.Scanner;
public class demo {
public static void main(String[] args) {
/* StringBuffer sb= new StringBuffer();
sb.append("liangchucheng");
System.out.println(sb);
change(sb);
System.out.println(sb);
}
public static void change(StringBuffer sb) {
sb.append("haohao xuexi");
// TODO Auto-generated method stub
*/
}
/*public static void retoString(String line){
StringBuffer sb=new StringBuffer(line);
sb.toString();
sb.reverse();
System.out.println(sb);
}*/
/*public static void main(String[] args) {
String s="liangshucheng";
System.out.println(s);
change(s);
System.out.println(s);
public static void change(String s) {
s="huhu"+s;
// TODO Auto-generated method stub
}*/
/*Scanner sc=new Scanner(System.in);
System.out.println("请输入一个字符串");
String line=sc.nextLine();
retoString(line);*/
/*StringBuffer sb=new StringBuffer(line);
sb.toString();
sb.reverse();
System.out.println(sb);*/
/*StringBuffer sb=new StringBuffer("heima");
sb.deleteCharAt(4);
sb.delete(0, 2);//只删除头,但是不删除尾部
StringBuffer sv=new StringBuffer("liangchuchengjiayouhaohaoxuexijiuhaole");
sv.delete(0,sv.length());
System.out.println(sv);
System.out.println(sb);
*/
/*StringBuffer sb=new StringBuffer("heima");
sb.replace(0, 3, "bai");
sb.reverse();
sb.append("liangshuchenghaohaoxuexi");
// sb.subSequence(0, 4);
String j=sb.substring(0,4);
System.out.println(j);*/
/*System.out.println(Math.PI);
n System.out.println("HELLO WORLD");
System.out.println(Math.abs(10));
*/
/*Random r=new Random();
int x = r.nextInt();
for(int i=0; i<20;i++){
System.out.println(r.nextInt());
}*/
/*Date d1= new Date();
System.out.println(d1);
Date d2= new Date(0);
System.out.println(d2);
System.out.println(d1.getTime());
System.out.println(d1.getTimezoneOffset());
}*/
/*public static void change(String s) {
s="huhu"+s;
// TODO Auto-generated method stub
}*/
}
package changjiandeotherclass;
public class erfenfa {
public static void main(String[] args) {
int[] arr={1,2,3,4,6,7,8,9};
System.out.println(index(arr,4));
// TODO Auto-generated method stub
}
public static int index(int[] arr,int value){
int min=0;
int max=arr.length-1;
int mid=(min+max)/2;
while (arr[mid]!=value){
if (arr[mid]<value){
mid+=1;
}else if(arr[mid]>value){
max=mid-1;
}
mid=(min+max)/2;
if(min>max){
return -1;
}
}
return mid;
}
}
package com.liangshucheng;
import java.util.ArrayList;
import java.util.Collection;
public class collection {
public static void main(String[] args){
Collection<String> sb=new ArrayList<String>();
sb.add("liang");
sb.add("shu");
sb.add("dage");
sb.add("lianhui");
// sb.add(new Student("梁树成",23));
Object[] su=sb.toArray();//通过转换成数组来进行遍历
for (int i = 0; i < su.length; i++) {
System.out.print(su[i]+ " ");
}
/*// sb.remove(2);根据索引删除元素
//sb.clear();//清空整个list
System.out.println(sb);
System.out.println(sb.contains("liang"));//判断arraylist中是否有某中元素
System.out.println(sb.isEmpty());//判断集合是否为空
System.out.println(sb.size());//获取元素的个数
*/ }
}
package com.liangshucheng;
import java.util.ArrayList;
import java.util.Collection;
public class Collections {
public static void main(String[] args) {
Collection c=new ArrayList();
c.add("a");
c.add("b");
c.add("c");
c.add("d");
Collection c1=new ArrayList();
c1.add("a");
c1.add("b");
c1.add("c");
c1.add("d");
// c.addAll(c1);//将每个元素单个的添加到c中
c.add(c1);//将c1整体当成一个添加到c中
// c.removeAll(c1);//上删除的是交集,没有交集的话就不能删除
c.retainAll(c1);//取交集 打印出来的是交集,也是一个BOOLEAN类型的 调用的集合变了就是ture 没有改变就是false
boolean s=c.containsAll(c1);//判断是否包含
System.out.println(c);
// TODO Auto-generated method stub
}
}
package com.liangshucheng;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
public class iterator {
public static void main(String[] args) {
Collection a=new ArrayList();
/*a.add("a");
a.add("b");
a.add("b");
a.add("ad");
Iterator it = a.iterator();//获取迭代器
while(it.hasNext()){//判断集合里面是否有元素
Object obj= it.next();//自动获取下一个元素
System.out.println(obj)*/;
}
// TODO Auto-generated method stub
}
}
package com.liangshucheng;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
public class list {
public static void main(String[] args) {
List list=new ArrayList();
list.add(new Student("张三",25));
/*list.add("liang");
list.add("shu");
list.add("cheng");
list.add("lianhui");*/
// list.set(index, element) 将制定索引的威位置,进行修改设置
//T通过迭代器的方式
// Iterator it=list.iterator();//获取迭代器
// while(it.hasNext()){ //判断list集合中是否是空值
Student st=(Student).it.next();//向下移动
// System.out.println(it.next());
// }
// 利用list的特有方式来遍历list集合,通过index和list.size()
/*for (int i = 0; i < list.size();i++) {
System.out.println(list.get(i));
}
*/
}
}