
Java培训课程教学资料
5星
- 浏览量: 0
- 大小:None
- 文件类型:None
简介:
《Java培训课程教学资料》是一套全面而实用的学习材料,专为初学者和中级开发者设计。涵盖核心概念、框架应用及实战项目,助力快速掌握Java技能。
《Java就业培训教程》 作者:张孝祥
书中P34源码程序清单如下所示:
```java
class Promote {
public static void main(String args[]) {
byte b = 50;
char c = a; // 注意此处应为单引号包含的字符,原文可能有误。
short s = 1024;
int i = 50000;
float f = 5.67f;
double d = .1234;
double result = (f * b) + (i / c) - (d * s);
System.out.println((f * b) + + + (i / c) + - + (d * s));
System.out.println(result = + result);
}
}
```
书中P35源码程序清单如下所示:
```java
public class TestScope {
public static void main(String[] args) {
int x = 12;
{
int q = 96; // 此时x和q都可用。
System.out.println(x is + x);
System.out.println(q is + q);
// 下面的行错误,只有变量x在此作用域中有效,而q已经超出其范围。
}
q = x;
}
}
```
书中P37源码程序清单如下所示:
```java
public class TestVar {
public static void main(String [] args) {
int x;
// 此处应改为int x=0,否则x未初始化将导致编译错误。
x=x+1;
System.out.println(x is +x);
}
}
```
书中P39源码程序清单如下所示:
```java
public class Func2 {
public static void drawRectangle(int x, int y) {
for (int i = 0; i < x; i++) {
for (int j = 0; j < y; j++) {
System.out.print( * );
}
// 换行
System.out.println();
}
// 再次换行以分隔矩形输出。
System.out.println();
}
public static void main(String [] args) {
drawRectangle(3, 5);
drawRectangle(2, 4);
drawRectangle(6, 10);
}
}
```
书中P47源码如下所示:
```java
public class TestAnd {
public static void main(String[] args) {
int x = 0;
int y = 0;
if (x != 0 && y == y / x)
System.out.println(y = + y);
}
}
```
书中P48源码程序清单如下所示:
```java
public class ShiftTest {
public static void main(String [] args) {
int x=0x80000000;
int y=0x80000000;
// 位移操作
x=x>>1;
y=y>>>1;
System.out.println(0x80000000>>1 = + Integer.toHexString(x));
System.out.println(0x8000000
全部评论 (0)


