八大数据类型及其转换
Posted 徐轻风
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了八大数据类型及其转换相关的知识,希望对你有一定的参考价值。
数据类型的两类
基本数据类型
- 数值类型
** 整数类型
- byte-1字节
2.short-2字节
3.int-4字节
4.long-8字节
** 浮点类型 - float-4
2.double-8
- boolean型:占一位,其值只有true和false
引用数据类型
- 表
2.接口
3.数组
public class Dog { static double salary=2500;//类变量 String a="missxu";//实例变量 public static void main(String[] args){ int b=5; int i=3;//局部变量(在方法里的变量,必须赋值) float d=3.145f; System-out-println(i); System-out-println(d); System-out-println((float)i);//自动类型转换 System-out-println(salary); Dog dog=new dog();//new Dog().var+回车 System-out-println(dog.a) double pow=Math.pow(i,b);//i的b次方Math.pow(i,b)按alt+回车 }
以上是关于八大数据类型及其转换的主要内容,如果未能解决你的问题,请参考以下文章