java ¹Ø¼ü×Ö
Java¹Ø¼ü×Ö£¨keywords£©
abstract default if private this
boolean do implements protected throw
break double import public throws
byte else instanceof return transient
case extends int short try
catch final interface static void
char finally long strictfp volatile
class float native super while
const for new switch
continue goto package synchronized
ÒÔÉÏÊÇjava specificationsÖж¨ÒåµÄkeywords£¬Ò»¹²48¸ö£¬ÆäÖг£¼ûµÄÈý¸ö¿´ËÆÊǹؼü×ÖµÄtrue, false, null,¶¼²»Êǹؼü×Ö£¬¶øÊÇ×÷Ϊһ¸öµ¥¶À±êʶÀàÐÍ¡£
ÆäÖУ¬²»³£Óõ½µÄ¹Ø¼ü×ÖÓУºconst£¬goto£¬native£¬strictfp£¬transient£¬volatile¡£
constºÍgotoΪjavaÖеı£Áô×Ö¡£
1. native
nativeÊÇ·½·¨ÐÞÊηû¡£Native·½·¨ÊÇÓÉÁíÍâÒ»ÖÖÓ
Ïà¹ØÎĵµ£º
C++ÓëJavaµÄÓï·¨Çø±ð
Ê×ÏÈ£¬Á½¸ö´óµÄ²»Í¬ÊÇÖ÷º¯ÊýºÍÔõÑù±àÒëµÄ²»Í¬£¬½ÓÏÂÀ´ÊÇÐí¶àСµÄÇø±ð¡£
main º¯Êý
C++
//×ÔÓɸ¡¶¯µÄº¯Êý
int main( int argc, char* argv[])
{
printf( "Hello, world" );
}
Java
// ÿ¸öº¯Êý¶¼±ØÐëÊÇÒ»¸öÀàµÄÒ»²¿·Ö;µ±java <class>ÔËÐÐÊÇÒ»¸öÌØ¶¨ÀàµÄÖ÷º¯Êý»á±»µ÷ ......
Ò»¸öjavaÎļþÖУ¬ÓÐÇÒÖ»ÓÐÒ»¸öpublicÀà
float ff= 1.3f;(4B)
int 4B;
long 8B;
double 8B;
byte Ò»×Ö½ÚÕûÐÍ
char 2B
Êý×é
int num[] = new int[3];
int[] num;
num = new int[3];
int [] num = new int[]{1,2,3};
int [][] num;
num = new int[3][4];
//²»Í¬³¤
num = new int[3][];
num[0] = new int[5]; ......
import java.util.LinkedList;
//µ¥Ïò¶ÓÁÐ
public class Queue {
public Queue() {
}
private LinkedList list = new LinkedList();
public void pu ......
/*ÏȰÑÏÂÔØµÄÎļþ·ÅÔÚUpdateTempÎļþ¼ÐÖУ¬´ýÈ«²¿ÏÂÔØºó£¬ÔÙ°Ñ´ËÎļþ¼ÐÖеÄÎļþÒÆ³öÌæ»»¾ÉÎļþ*/
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
......
importjava.text.DecimalFormat;
¡¡¡¡
publicclassTestNumberFormat{
¡¡¡¡
¡¡¡¡publicstaticvoidmain(String[]args){
¡¡¡¡¡¡¡¡doublepi=3.1415927;¡¡//Ô²ÖÜÂÊ
¡¡¡¡¡¡¡¡//ȡһλÕûÊý
¡¡¡¡¡¡¡¡System.out.println(newDecimalFormat("0").format(pi));¡¡¡¡¡¡//3
¡¡¡¡¡¡¡¡//ȡһλÕûÊýºÍÁ½Î»Ð¡Êý
¡¡¡¡¡¡¡¡System ......