首页 > 其他分享 >数据类型学习

数据类型学习

时间:2023-03-15 11:45:07浏览次数:28  
标签:String int 数据类型 System 学习 println public out

JAVA

Write Once Run anywhere

JDK:java开发者工具

JRE:java 运行时环境

JVM:java虚拟机

image-20230314153055596

Hello world

public class HelloWorld {
    public static void main(String[] args) {

        System.out.println("hello,world!");
    }
}

public class Demo1 {
    public static void main(String[] args) {
        String a = "hello";
        int b = 10;
        System.out.println(a+b);

    }
}

基础数据类型

public class Demo2 {
    public static void main(String[] args) {
        //八大基本数据类型
        //整数

        int num1 = 10;
        byte num2 = 20;
        short num3  = 30;
        long num4 = 40;

        //小数:浮点数
        float num5 = 50.1F;
        double num6 = 3.14159265358979;

        //字符串
        char name = '牛';
        //string name1 = "赵云";

        //布尔值:是非
        boolean flag = true;
        boolean flag1 = false;
    }
}

数据类型扩展

public class Demo3 {
    public static void main(String[] args) {
        int i = 10;
        int i2 = 010; //八进制
        int i3 = 0x11; //十六进制0x


        System.out.println(i);
        System.out.println(i2);
        System.out.println(i3);
        System.out.println("==================================================================");
        //BigDecimal  数学工具类

         float f = 0.1f; //0.1
         double d = 1.0/10; //0.1
        System.out.println(f==d);
        System.out.println(f);
        System.out.println(d);

        float f1 = 1231654321321465431f;
        float d1 = f1 + 1;
        System.out.println(d1);
        System.out.println(d1==f1);

        System.out.println("==================================================================");

        char c1 = 'a';
        char c2 = '国';

        System.out.println(c1);
        System.out.println((int)c1); //强制转换

        System.out.println(c2);
        System.out.println((int)c2); //强制转换

        //所有的字符本质还是数字
        // 编码 Unicode

        System.out.println("hello\nworld");

        System.out.println("==================================================================");
        String ca = new String("hello world");
        String cb = new String("hello world");
        System.out.println(ca==cb);

        String cc = "helloworld";
        String cd = "helloworld";
        System.out.println(cc==cd);

        //布尔值扩展
        boolean flag = true;
        int a6 = 5;
        if (flag == true) {
            //if (flag)
            System.out.println("正确");
        }

    }
}

标签:String,int,数据类型,System,学习,println,public,out
From: https://www.cnblogs.com/lxb426/p/17217936.html

相关文章

  • 快速莫比乌斯/沃尔什变换 (FMT/FWT) 学习笔记
    引入考虑一个基本问题:给定序列\(a_n,b_n\),求出序列\(c_n\),满足\(c_i=\sum_{j\oplusk=i}a_jb_k\),其中\(\oplus\)是一种二元运算符,形如上式的问题一般被称为卷积。......
  • python入门学习-3.多线程、多进程、网络通信
    进程和线程多任务线程是最小的执行单元,而进程由至少一个线程组成。多进程Linux操作系统提供了一个fork()系统调用,子进程返回0,父进程返回子进程的ID。调用getpid()可以......
  • PyTorch学习记录(三):onnx模型部署
    原则:PythonforTrainingC++forInferencePyTorch模型导出:PyTorch使用.pth文件来对神经网络的权重进行保存,.pth文件中的模型权重则是按照字典格式进行保存的,但是.pth......
  • AS学习日记--第五天
    完善登录界面和跳转以及学习了Toast和结束登录注册界面     ......
  • Maven学习笔记1:Maven基本介绍和安装配置
    一、认识Maven官网http://maven.apache.org/上面有最权威的说明,其中包括下载、安装、运行示例,但是是英文版的。Maven是什么Maven是一个项目管理工具。它有何优点呢?......
  • 学习笔记——Python基础
    字符串索引str='我是一名学生'print(str[0])#输出“我”print(str[-6])#输出“我”字符串切片:把数据对象的一部分拿出来str='我是一名学生'pri......
  • python+playwright 学习-31 事件添加与删除
    前言Playwright允许监听网页上发生的各种类型的事件,例如网络请求、子页面的创建、dedicatedworkers等。等待特定事件大多数时候,脚本需要等待特定事件的发生。下面是......
  • 某钉自动打卡示例(仅供学习,不喜勿喷)
    importrequestsimportjson#钉钉API地址和access_token,根据实际情况修改url="https://oapi.dingtalk.com/attendance/v1/advanced/record/create"access_token=......
  • C# 并发编程学习笔记
    术语含义并发:同时做多件事情;多线程:并发的一种形式,它采用多个线程来执行程序;并行处理:把正在执行的大量任务分割成小块,分配给多个同时运行的线程;异步编程:并发的一种形式,......
  • oracle学习笔记1 安装 虚拟机 plsql 连接 oracle
    第一步就是安装为了节省资源,运行起来更快捷,首先是在电脑上安装好vm虚拟机,新建虚拟机,安装xp,也就是把xp光盘文件导入,接着在虚拟机中下载oracle,解压的话会用到WinRAR,也一......