zoukankan      html  css  js  c++  java
  • jdk源码_String(1)

    package com.example.demo;
    
    public class Sort {
        //java源码之string
        public static void main(String[] args) {
            {//空字符对象创建字符串
                String s = new String();
                System.out.println(s);
            }
    
            {
                //字符串对象创建字符串
                String s = new String("a");
                System.out.println(s);
            }
            {
                //字符数组方式声明字符串
                char[] c = {'a', 'b', 'c'};
                String s = new String(c);
                System.out.println(s);
            }
            {
                /**
                 *  // Note: offset or count might be near -1>>>1.
                 if (offset > value.length - count) {
                 throw new StringIndexOutOfBoundsException(offset + count);
                 意思是
                 -1>>>1 相当于 integer.maxvalue()
                 如果offset + count > value.length 可能会溢出
                 而 offset > value.length - count 则不会
                 >>>代表无符号又移
                 整数源反补都一样
                 负数源码第一位是符号位
                 负数反码 符号位不变,参照源码其他位按位取反
                 符数补码 符号位不变 参照源码 按位取反 末位加一
    
                 }
                 */
                //截取字符串
                char[] a = {'a', 'd', 'f', 'r', 'd', 'e'};
                String s = new String(a, 2, 4);
                System.out.println(s);
            }
    
        }
    }
  • 相关阅读:
    HTML的基础
    样式表
    页面布局
    for 循环
    函数
    数组
    样式属性
    css选择器参考手册
    样式表格及选择器
    表单
  • 原文地址:https://www.cnblogs.com/xiaoshahai/p/12872448.html
Copyright © 2011-2022 走看看