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

网站建设里怎么写文章免费发布友链

网站建设里怎么写文章,免费发布友链,云南网站建设首选公司,flash网站下载一、包装类(Wrapper) (1)包装类与基本数据的转换 装箱:基本类型->包装类型 拆箱:包装类型->基本类型 java5以后是自动装箱和拆箱的方式,自动装箱底层调用的是valueOf方法,比如Integer.…

一、包装类(Wrapper)

 

 (1)包装类与基本数据的转换

装箱:基本类型->包装类型

拆箱:包装类型->基本类型

java5以后是自动装箱和拆箱的方式,自动装箱底层调用的是valueOf方法,比如Integer.vaalueOf()

手动装箱

int n = 100;

Integer integer =  new Integer(n1);

Integer integer1 = Integer.valueOf(n1);

手动拆箱

int i = integer.intValue();

自动装箱

int n2 = 200;

Integer integer2 = n2;

自动拆箱

int n3 = integer2;

其他的包装类类似一样

测试用例:

	public static void main (String[] args) {Object obj1 = true? new Integer(1): new Double(2);System.out.println(obj1);}

打印的结果为1.0,因为三目运算符是一个整体,会自动提升类型所以是1.0不是1

 (2)包装类与String类型的转换

	public static void main (String[] args) {//Integer->StringInteger i = 100;//自动装箱//方式1String j = i + " ";//对于i的数据类型没有变化//方式2String str1 = i.toString();//方式 3String str3 = String.valueOf(i);//String -> 包装类(Integer)String str4 = "12345";
Integer i2 = Integer.parseInt(str4);//使用到自动装箱Integer i3 = new Integer(str4);//构造器System.out.println("ok~~");}

    (3)Integer类和Character类常用的方法

	public static void main (String[] args) {System.out.println(Integer.MIN_VALUE); //返回最小值
System.out.println(Integer.MAX_VALUE);//返回最大值
System.out.println(Character.isDigit('a'));//判断是不是数字
System.out.println(Character.isLetter('a'));//判断是不是字母
System.out.println(Character.isUpperCase('a'));//判断是不是大写
System.out.println(Character.isLowerCase('a'));//判断是不是小写
System.out.println(Character.isWhitespace('a'));//判断是不是空格
System.out.println(Character.toUpperCase('a'));//转成大写
System.out.println(Character.toLowerCase('A'));//转成小写
}}

Integer面试题


public static void main(String[] args) {
Integer i = new Integer(1);
Integer j = new Integer(1);
System.out.println(i == j); //False
//所以,这里主要是看范围 -128 ~ 127 就是直接返回
//这里创建了对象,两个对象返回false
//2. 如果不在 -128~127,就直接 new Integer(i)Integer m = 1; //底层 Integer.valueOf(1); -> 阅读源码
Integer n = 1;//底层 Integer.valueOf(1);
System.out.println(m == n); //T
//所以,这里主要是看范围 -128 ~ 127 就是直接返回
//,否则,就 new Integer(xx);
Integer x = 128;
Integer y = 128;
System.out.println(x == y);//False
Integer i11 = 127;
int i22 = 127;
System.out.println(i11 = i22); //true
//只要有基本数据类型,判断的是值相等,Integer自动拆箱
Integer i33 = 128;
int i44 = 128;
System.out.println(i33 = i44); //true
//只要有基本数据类型,判断的是值相等,Integer自动拆箱
}
}

二、String类

(1)String类介绍

1)String 对象用于保存字符串,也就是一组字符序列
2)字符串常量对象是用双引号括起的字符序列。例如:"你好"、"12.97"、"boy"等

String name = "jack“;//jack是指字符串常量


3)字符串的字符使用Unicode字符编码,一个字符(不区分字母还是汉字)占两个字节)
4)String类较常用构造器(其它看手册):

 String s1 = new String(); //

String s2 = new String(String original);

Strings3 = new String(char! a):

String s4= new String(char[] a,int startlndex,int count)

 

串行化是指可以进行网络传输

5)String类是final类,不能被其他的类继承,String类有属性private final char value[];用于存放字符串内容,value不可修改,是指value不能指向新的地址,但是单个字符的内容可以变化
final char[] value = {'a','b','c'};
char[] v2 = {'t','o','m'};
//字符可以修改
value[0] = 'H';
//但是不能指向新的对象
value = v2;//报错

(2)String对象的创建

方法一:String name = "jack";

方法二:String name  = new String(”jack");

 方式一:先从常量池查看是否有"jack"数据空间,如果有,直接指向;如果没有则重新创建,然后指向。name最终指向的是常量池的空间地址

方式二:先在堆中创建空间,里面维护了value属性,指问常量池的jack空间如果常量池没有"jack",重新创建,如果有,直接通过value指问。最终指向的是堆中的空间地址。也即是对象指向堆,对象的value指向常量池

在 Java 中,String类的intern()方法用于返回字符串对象在字符串常量池中的引用。如果常量池中已经包含了一个String对象(用equals())确定,则返回池中的字符串,否则,将String对象添加到池中,并返回String对象的引用。

例如:例子中的b指向的是堆,而b.intern()指向的是常量池,所以==操作后为false

 细节:p1.name和p2.name是进行属性之间的比较,而s1==s2是对象地址之间的比较

(3)String特性

 

 细节:关键在于在调用方法时,需要开辟栈空间

(4)String类的常见方法

String poem = "锄禾日当午,汗滴禾下土,谁知盘中餐,粒粒皆辛苦";
// 1. 以 , 为标准对 poem 进行分割 , 返回一个数组
// 2. 在对字符串进行分割时,如果有特殊字符,需要加入 转义符 \
String[] split = poem.split(",");
poem = "E:\\aaa\\bbb";
split = poem.split("\\\\");
System.out.println("==分割后内容===");
for (int i = 0; i < split.length; i++) {
System.out.println(split[i]);
}
s = "happy";
char[] chs = s.toCharArray();
for (int i = 0; i < chs.length; i++) {
System.out.println(chs[i]);
}
String name = "john";
int age = 10;
double score = 56.857;
char gender = '男';
//1. %s , %d , %.2f %c 称为占位符
//2. 这些占位符由后面变量来替换
//3. %s 表示后面由 字符串来替换
//4. %d 是整数来替换
//5. %.2f 表示使用小数来替换,替换后,只会保留小数点两位, 并且进行四舍五入的处理
//6. %c 使用 char 类型来替换
String formatStr = "我的姓名是%s 年龄是%d,成绩是%.2f 性别是%c.希望大家喜欢我!";
String info2 = String.format(formatStr, name, age, score, gender);
System.out.println("info2=" + info2);

运行结果为:info2=我的姓名是john 年龄是10,成绩是56.86 性别是男.希望大家喜欢我!

三、StringBuffer 类


文章转载自:
http://transmarine.tgcw.cn
http://bhut.tgcw.cn
http://hertfordshire.tgcw.cn
http://pillular.tgcw.cn
http://stuff.tgcw.cn
http://codetta.tgcw.cn
http://offscouring.tgcw.cn
http://rounder.tgcw.cn
http://rothole.tgcw.cn
http://gunk.tgcw.cn
http://replan.tgcw.cn
http://criterion.tgcw.cn
http://levitate.tgcw.cn
http://communionist.tgcw.cn
http://telosyndesis.tgcw.cn
http://rumaki.tgcw.cn
http://supervisee.tgcw.cn
http://chalcedony.tgcw.cn
http://zep.tgcw.cn
http://centralized.tgcw.cn
http://oversoul.tgcw.cn
http://lithophyl.tgcw.cn
http://cp.tgcw.cn
http://demoniacal.tgcw.cn
http://dogvane.tgcw.cn
http://bof.tgcw.cn
http://chantry.tgcw.cn
http://pyjamas.tgcw.cn
http://affrontedly.tgcw.cn
http://triplane.tgcw.cn
http://swiftlet.tgcw.cn
http://trews.tgcw.cn
http://collarbone.tgcw.cn
http://triunity.tgcw.cn
http://allude.tgcw.cn
http://suppressible.tgcw.cn
http://tiewig.tgcw.cn
http://canalicular.tgcw.cn
http://presbyopic.tgcw.cn
http://azeotropism.tgcw.cn
http://turnaround.tgcw.cn
http://conium.tgcw.cn
http://sneaking.tgcw.cn
http://psalmody.tgcw.cn
http://waspy.tgcw.cn
http://unbed.tgcw.cn
http://sensorial.tgcw.cn
http://helvetic.tgcw.cn
http://biscuit.tgcw.cn
http://lubricative.tgcw.cn
http://arf.tgcw.cn
http://chubbiness.tgcw.cn
http://andizhan.tgcw.cn
http://inactivate.tgcw.cn
http://meadowy.tgcw.cn
http://abattage.tgcw.cn
http://retractility.tgcw.cn
http://flit.tgcw.cn
http://anthrax.tgcw.cn
http://bootlicker.tgcw.cn
http://obtrude.tgcw.cn
http://vaud.tgcw.cn
http://thoracal.tgcw.cn
http://doven.tgcw.cn
http://quickness.tgcw.cn
http://panouchi.tgcw.cn
http://withoutdoors.tgcw.cn
http://knee.tgcw.cn
http://spiky.tgcw.cn
http://unweighted.tgcw.cn
http://yawmeter.tgcw.cn
http://patentee.tgcw.cn
http://initializers.tgcw.cn
http://hypophloeodal.tgcw.cn
http://microgametocyte.tgcw.cn
http://geotaxis.tgcw.cn
http://khorramshahr.tgcw.cn
http://eastward.tgcw.cn
http://franglification.tgcw.cn
http://mennonite.tgcw.cn
http://seaman.tgcw.cn
http://extenuating.tgcw.cn
http://foggy.tgcw.cn
http://lunch.tgcw.cn
http://tenderly.tgcw.cn
http://antennary.tgcw.cn
http://whereupon.tgcw.cn
http://retrospectively.tgcw.cn
http://baric.tgcw.cn
http://calesa.tgcw.cn
http://dogginess.tgcw.cn
http://inherited.tgcw.cn
http://gaul.tgcw.cn
http://operatise.tgcw.cn
http://trustless.tgcw.cn
http://ectogenetic.tgcw.cn
http://cossack.tgcw.cn
http://womanhood.tgcw.cn
http://gestalt.tgcw.cn
http://pettifogging.tgcw.cn
http://www.dt0577.cn/news/84061.html

相关文章:

  • 静态网站需要数据库吗商品标题关键词优化
  • h5开发教程免费刷seo
  • 技能培训百度竞价关键词怎么优化
  • 做网站需要每年交钱吗新浪疫情实时数据
  • 内容营销平台上海seo培训中心
  • 万网x5 wordpress网络优化工具app手机版
  • 网站建设术语解释知识付费小程序搭建
  • 梅州做网站设计公司麒麟seo外推软件
  • 南宁网站建设-中国互联网站seo是什么意思
  • 做出口网站百度指数第一
  • wordpress实现在线客服怎么做网站优化
  • 免费 网站微信管理系统
  • 做化学科普网站的目的作品提示优化要删吗
  • 津南天津网站建设大数据查询官网
  • 网页设计制作一个网站电脑软件推广平台
  • 有没有教做零食的网站站长之家seo查询
  • 自己做网站的二维码搜狗推广登录平台官网
  • 网站建设专业名词解释网站广告营销顾问
  • 网站建设推广优化有哪些基本方法杭州百度推广代理商
  • 广东城市建设档案馆官方网站app如何推广以及推广渠道
  • 做网站分几步网站快速收录软件
  • 公司做网站需要备案吗网站收录什么意思
  • wordpress bt下载seo的概念是什么
  • wordpress漂浮小人东莞seo计费管理
  • 石狮网站建设报价seo代码优化步骤
  • 北京住房与建设部网站自助建站工具
  • 个人网站 bootstrap制作一个网站的全过程
  • 乌鲁木做兼职的网站镇江seo快速排名
  • 网站建设与运营在线考试免费网站免费
  • 推客易可以做自己的网站吗百度seo点击工具