没有合适的资源?快使用搜索试试~ 我知道了~
首页Prentice Hall.Introduction.to.Java.Programming.Comprehensive.8th.Edition
Prentice Hall.Introduction.to.Java.Programming.Comprehensive.8th...
5星 · 超过95%的资源 需积分: 33 41 下载量 13 浏览量
更新于2023-03-03
评论 2
收藏 17.96MB PDF 举报
Prentice Hall.Introduction.to.Java.Programming.Comprehensive.8th.Edition
资源详情
资源评论
资源推荐
Console Input
Scanner input = new Scanner(System.in);
int intValue = input.nextInt();
long longValue = input.nextLong();
double doubleValue = input.nextDouble();
float floatValue = input.nextFloat();
String string = input.next();
Console Output
System.out.println(anyValue);
Primitive Data Types
byte 8 bits
short 16 bits
int 32 bits
long 64 bits
float 32 bits
double 64 bits
char 16 bits
boolean true/false
Relational Operators
< less than
<= less than or equal to
> greater than
>= greater than or equal to
== equal to
!= not equal
Logical Operators
&& short circuit AND
|| short circuit OR
! NOT
^ exclusive OR
Arithmetic Operators
+ addition
- subtraction
* multiplication
/ division
% remainder
++var preincrement
--var predecrement
var++ postincrement
var-- postdecrement
switch Statements
switch (intExpression) {
case value1:
statements;
break;
...
case valuen:
statements;
break;
default:
statements;
}
Companion Web site: www.pearsonhighered.com/liang
Assignment Operators
= assignment
+= addition assignment
-= subtraction assignment
*= multiplication assignment
/= division assignment
%= remainder assignment
if Statements
if (condition) {
statements;
}
if (condition) {
statements;
}
else {
statements;
}
if (condition1) {
statements;
}
else if (condition2) {
statements;
}
else {
statements;
}
loop Statements
while (condition) {
statements;
}
do {
statements;
} while (condition);
for (init; condition;
adjustment) {
statements;
}
Java Quick Reference
GUI Input Dialog
String string = JOptionPane.showInputDialog(
"Enter input");
int intValue = Integer.parseInt(string);
double doubleValue =
Double.parseDouble(string);
Message Dialog
JOptionPane.showMessageDialog(null,
"Enter input");
Frequently Used Static Constants/Methods
Math.PI
Math.random()
Math.pow(a, b)
System.currentTimeMillis()
System.out.println(anyValue)
JOptionPane.showMessageDialog(null,
message)
JOptionPane.showInputDialog(
prompt-message)
Integer.parseInt(string)
Double.parseDouble(string)
Arrays.sort(type[] list)
Arrays.binarySearch(type[] list, type key)
Array/Length/Initializer
int[] list = new int[10];
list.length;
int[] list = {1, 2, 3, 4};
Multidimensional Array/Length/Initializer
int[][] list = new int[10][10];
list.length;
list[0].length;
int[][] list = {{1, 2}, {3, 4}};
Ragged Array
int[][] m = {{1, 2, 3, 4},
{1, 2, 3},
{1, 2},
{1}};
String Class
String s = "Welcome";
String s = new String(char[]);
int length = s.length();
char ch = s.charAt(index);
int d = s.compareTo(s1);
boolean b = s.equals(s1);
boolean b = s.startsWith(s1);
boolean b = s.endsWith(s1);
String s1 = s.trim();
String s1 = s.toUpperCase();
String s1 = s.toLowerCase();
int index = s.indexOf(ch);
int index = s.lastIndexOf(ch);
String s1 = s.substring(ch);
String s1 = s.substring(i,j);
char[] chs = s.toCharArray();
String s1 = s.replaceAll(regex,repl);
String[] tokens = s.split(regex);
Companion Web site: www.pearsonhighered.com/liang
Object Class
Object o = new Object();
o.toString();
o.equals(o1);
File Class
File file =
new File(filename);
file.exists()
file.renameTo(File)
file.delete()
Text File Output
PrintWriter output =
new PrintWriter(filename);
output.print(...);
output.println(...);
output.printf(...);
Text File Input
Scanner input = new Scanner(
new File(filename));
ArrayList Class
ArrayList<E> list = new ArrayList<E>();
list.add(object);
list.add(index, object);
list.clear();
Object o = list.get(index);
boolean b = list.isEmpty();
boolean b = list.contains(object);
int i = list.size();
list.remove(index);
list.set(index, object);
int i = list.indexOf(object);
int i = list.lastIndexOf(object);
printf Method
System.out.printf("%b %c %d %f %e %s",
true, 'A', 45, 45.5, 45.5, "Welcome");
System.out.printf("%-5d %10.2f %10.2e %8s",
45, 45.5, 45.5, "Welcome");
Comparable Interface
c.compareTo(Comparable)
c is a Comparable object
Java Quick Reference
INTRODUCTION TO
JAVA
PROGRAMMING
COMPREHENSIVE VERSION
Eighth Edition
Y. Daniel Liang
Armstrong Atlantic State University
Boston Columbus Indianapolis New York San Francisco Upper Saddle River
Amsterdam Cape Town Dubai London Madrid Milan Munich Paris Montreal Toronto
Delhi Mexico City Sao Paulo Sydney Hong Kong Seoul Singapore Taipei Tokyo
Prentice Hall
TM
Vice President and Editorial Director, ECS: Marcia J. Horton
Editor in Chief, Computer Science: Michael Hirsch
Executive Editor: Tracy Dunkelberger
Assistant Editor: Melinda Haggerty
Editorial Assistant: Allison Michael
Vice President, Production: Vince O’Brien
Senior Managing Editor: Scott Disanno
Production Editor: Irwin Zucker
Senior Operations Specialist: Alan Fischer
Marketing Manager: Erin Davis
Marketing Assistant: Mack Patterson
Art Director: Kenny Beck
Cover Image: Male Ruby-throated Hummingbird / Steve Byland / Shutterstock;
Hummingbird, Nazca Lines / Gary Yim / Shutterstock
Art Editor: Greg Dulles
Media Editor: Daniel Sandin
Copyright © 2011, 2009, 2007, 2004 by Pearson Higher Education. Upper Saddle River, New Jersey, 07458.
All right reserved. Manufactured in the United States of America. This publication is protected by Copyright and
permission should be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval sys-
tem, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. To
obtain permission(s) to use materials from this work, please submit a written request to Pearson Higher Education,
Permissions Department, 1 Lake Street, Upper Saddle River, NJ 07458.
The author and publisher of this book have used their best efforts in preparing this book. These efforts include the
development, research, and testing of the theories and programs to determine their effectiveness. The author and
publisher make no warranty of any kind, expressed or implied, with regard to these programs or the documentation
contained in this book. The author and publisher shall not be liable in any event for incidental or consequential
damages in connection with, or arising out of, the furnishing, performance, or use of these programs.
Library of Congress Cataloging-in-Publication Data on file.
10 9 8 7 6 5 4 3 2 1
ISBN-13: 978-0-13-213080-6
ISBN-10: 0-13-213080-7
剩余1370页未读,继续阅读
DoomLord
- 粉丝: 114
- 资源: 1319
上传资源 快速赚钱
- 我的内容管理 收起
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
会员权益专享
最新资源
- stc12c5a60s2 例程
- Android通过全局变量传递数据
- c++校园超市商品信息管理系统课程设计说明书(含源代码) (2).pdf
- 建筑供配电系统相关课件.pptx
- 企业管理规章制度及管理模式.doc
- vb打开摄像头.doc
- 云计算-可信计算中认证协议改进方案.pdf
- [详细完整版]单片机编程4.ppt
- c语言常用算法.pdf
- c++经典程序代码大全.pdf
- 单片机数字时钟资料.doc
- 11项目管理前沿1.0.pptx
- 基于ssm的“魅力”繁峙宣传网站的设计与实现论文.doc
- 智慧交通综合解决方案.pptx
- 建筑防潮设计-PowerPointPresentati.pptx
- SPC统计过程控制程序.pptx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论5