1 / 245
文档名称:

Java面向对象程序.pptx

格式:pptx   大小:7,448KB   页数:245页
下载后只包含 1 个 PPTX 格式的文档,没有任何的图纸或源代码,查看文件列表

如果您已付费下载过本站文档,您可以点这里二次下载

分享

预览

Java面向对象程序.pptx

上传人:wz_198613 2021/3/23 文件大小:7.27 MB

下载得到文件列表

Java面向对象程序.pptx

文档介绍

文档介绍:一、Java编程基础

Type Name
Kind of value
Memory Used
Size Range
byte
integer
1 byte
-128 to 127
short
integer
2 bytes
-32768 to 32767
int
integer
4 bytes
-2147483648 to 2147483647
long
integer
8 bytes
-9223372036854775808 to …07
float
floating-point
4 bytes
+/-+38 to
+/--45
double
floating-point
8 bytes
+/-**********e+308 to
+/--324
char
character
(Unicode)
2 bytes
all Unicode characters
boolean
true of false
1bit
not applicable
1
牛牛文库文档分享
一、Java编程基础

(1)匿名常量
int x = 1;
float y = ;
char z = ‘A’;
boolean flag = true;
(2)命名常量
final double pi = ;
2
牛牛文库文档分享
一、Java编程基础

Scanner input = new Scanner();
double x = ();
int y = ();
Scanner的方法
nextByte()
nextShort(),nextInt(),nextLong()
nextFloat(),nextDouble()
next() //读取一个字
nextLine() //读取一行文本
3
牛牛文库文档分享
Console I/O

import .*;
public class ScannerDemo{
public static void main(String[] args){
int n1,n2;
Scanner scannerObject = new Scanner();
(“Enter two whole numbers:”);
n1 = ();
n2 = ();
//() reads one word
//() reads an entire line.
(“You entered “ + n1 + “ and “ + n2);
}
}
4
牛牛文库文档分享
一、Java编程基础

(“abc”);
(“abc”);
(“abc\n”);
5
牛牛文库文档分享
一、Java编程基础

char symbol;
symbol = ‘A’;
char ch = ‘B’;

int m;
m = 4;
int n = 5;
double x = ;
boolean male = true;
6
牛牛文库文档分享
一、Java编程基础

(1)强制类型转换
double distance = ;
int points = (int)distance;
char ch = ‘7’;
int a = (int)ch; //variable a has value 55.
(2)隐含类型转换
byteshortintlo