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 秒) - 正常终止
    

      

  • 相关阅读:
    Eighth scrum meeting
    Seventh scrum meeting
    Sixth scrum meeting
    Fifth scrum meeting
    Forth scrum meeting
    Third scrum meeting
    2019-07-25 L430 生物 GPS
    L429 Why Do Smart People Do Foolish Things?
    L427 长难句
    L426
  • 原文地址:https://www.cnblogs.com/rdchenxi/p/13197319.html
Copyright © 2011-2022 走看看