zoukankan      html  css  js  c++  java
  • 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 秒) - 正常终止
    

      

  • 相关阅读:
    基于easyUI实现权限管理系统(一)一—组织结构树图形
    基于jquery实现图片拖动和曲线拖放
    SOLID原则
    架构设计-C4
    中台战略
    DDD
    GraphQL
    kafka笔记
    maven
    GIT
  • 原文地址:https://www.cnblogs.com/rdchenxi/p/13197319.html
Copyright © 2011-2022 走看看