zoukankan      html  css  js  c++  java
  • 003-JavaString数据类型

    String类型可以和8中基本数据类型做运算(byte/short/char/int/long/float/double/boolean),且只能是连接运算

    1. 区分 连接符 和 “+” 的区别

    char c = 'a';
    int num = 10;
    String str = "hello";
    System.out.println(c + str + num); //ahello10
    System.out.println(str + (c + num));//hello107
    System.out.println(c + num + str);//107hello
    

    2.输出 “*  *”这样的一个字符串,其中字符串中间的空白是制表符

    System.out.println("*   *");//成功
    System.out.println('*' + '	' + '*');//93
    System.out.println('*' + '	' + "*");//51*,右上一行和本行,可得到*的ascii码值为42
    System.out.println('*' + "	" + '*');//成功
    System.out.println("*" + '	' + '*');//成功
    System.out.println('*' + ('	' + "*"));//成功
  • 相关阅读:
    异常
    带参数的方法
    变量,基本类型,数据类型和运算符
    数据类型转换(针对数字类型)
    this关键字
    面向对象DAO模式
    常见类 Object
    方法和包
    final关键字
    abstract关键字
  • 原文地址:https://www.cnblogs.com/Sinkinghost/p/10987607.html
Copyright © 2011-2022 走看看