• Java引用数据类型字符串


    String(字符串):引用数据类型

    声明String使用一对双引号

    string可以与8中数据类型做运算;且运算只能连接运算运算符+

    运算结果也是string类型  ;a = 97

    简单示例

    class VariableTest1
    {
    	public static void main(String[] args) 
    	{
    		String s1 = "chlgg";
    		System.out.println("Hello world");
    		System.out.println(s1);
    
    	}
    }
    ---------- java ----------
    Hello world
    chlgg
    
    输出完成 (耗时 0 秒) - 正常终止
    

      字符串拼接

    class VariableTest1
    {
    	public static void main(String[] args) 
    	{
    		String s1 = "chlgg";
    		System.out.println("Hello world");
    		System.out.println(s1);
    		int number = 1001;
    		String numberStr = "学号";
    		String info = numberStr + number;
    		System.out.println(info);
    
    	}
    }
    

      测试

    class VariableTest1
    {
    	public static void main(String[] args) 
    	{
    		char c = 'a';//a等于97
    		int num = 10;
    		String str = "hello";
    		System.out.println (c + num +str);
    		System.out.println(c + str + num);
    		System.out.println(c+ (num + str));
    		System.out.println((str + num +c));
    
    	}
    }
    ---------- java ----------
    107hello
    ahello10
    a10hello
    hello10a
    
    输出完成 (耗时 0 秒) - 正常终止
    

      

  • 相关阅读:
    new in swift
    Mac Git [remote rejected] master -> master (pre-receive hook declined) 解决方案
    Mac git 代码的Add 以及提交
    swift storyboard 跳转的2 种方式
    iOS 常用指令(svn cocoa pod)
    java面试题(晨星)
    谈Spring的理解
    软件产品开发文档大纲
    商城项目要点
    金蝶面试小记
  • 原文地址:https://www.cnblogs.com/rdchenxi/p/13197319.html
Copyright © 2020-2023  润新知