JAVA复习知识点总结-基础篇

本文详细介绍了Java编程的基础知识,包括程序开发流程、基本类型与复杂类型的区别、常用的结构语句、String类的操作方法以及数组的使用等核心内容。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1.chaine de developpement

programme source(.java)->programme binaire(.class)->machine virtuelle

2.types

type primitif基本类型:

byte(1) short(2) int(4) long(8)

float(4) double(8)

boolean(1)

char(1)

特点:可直接建立,不需要调用new方法。可以在内存里直接表示

type complexe复杂类型:

table

特点:间接获取数据

type construit

String

特点:数据+工具

3.结构

if(condition)
{
}else
{
}

switch (variable)
{
case n:
break;
....
default:
}

while(condition)
{
//条件为真,运行
}

do
{
}while(condition)
//条件为真,继续往下走

for(int i=0; i<n; i++)
{
}

4.String

初始化:

String chaine=new String("Windows a encore plante");

char[] T={'W','i','n','d','o','w','s',' ','a'};
String chaine1=new String(T);

String chaine2="Windows";

常用方法

string.length() return int

string.charAt(n) return 第n位字母

string.substring(n,m) return String截取n位与n位后m位前的字符串

sting.equals(String ) return boolean

string.indexOf('char') return int

string.lastIndexOf('char') return int

string.replace('char1','char2') return String char2替换char1

String chaine3=chaine2+chaine1

String.valueOf(valeur) return String 其他类型转字符串(static)


This method has followings variants, which depend on the passed parameters. This method returns the string representation of the passed argument.

  • valueOf(boolean b): Returns the string representation of the boolean argument.

  • valueOf(char c): Returns the string representation of the char argument.

  • valueOf(char[] data): Returns the string representation of the char array argument.

  • valueOf(char[] data, int offset, int count): Returns the string representation of a specific subarray of the char array argument.

  • valueOf(double d): Returns the string representation of the double argument.

  • valueOf(float f): Returns the string representation of the float argument.

  • valueOf(int i): Returns the string representation of the int argument.

  • valueOf(long l): Returns the string representation of the long argument.

  • valueOf(Object obj): Returns the string representation of the Object argument


字符串转其他类型
Integer.parseInt(chaine)
Long.parseLong(chaine)
Float.parseFloat(chaine)
Double.parseDouble(chaine)

5.Table

初始化

int[] Table;
Table=new int[10];

int[] T2={12,-33,44,0,12225}


table.length return int 

6.保留字和关键字

关键字列表 
 abstract抽象类 boolean break byte case  

 catch char class continue default 

 do double else extends false 

 final finally float for if 

 implements   import  instanceof int interface 

 long  native   new  null   package 

 private   protected  public  return short 

 static   super   switch   synchronized  this 

 throw   throws  transient   true  try 

 void   volatile  while 
保留字 
 const,goto 
 所有的关键字都是小写 

关于throw和throws,此处引用一个栗子(出自《programmer en JAVA》-Claude Delannoy)

class Point
{
<span style="white-space:pre">	</span>public Point(int x, int y) throws ErrConst//throws修饰方法,加一个由Exception构造的class
<span style="white-space:pre">	</span>{
<span style="white-space:pre">		</span>if((x<0) || (y<0)) throw new ErrConst();//throw 是指令
<span style="white-space:pre">		</span>this.x=x;
<span style="white-space:pre">		</span>this.y=y;
<span style="white-space:pre">	</span>}
<span style="white-space:pre">	</span>public void affiche()
<span style="white-space:pre">	</span>{
<span style="white-space:pre">		</span>System.out.println("coordonnees: "+x+" "+y);
<span style="white-space:pre">	</span>}
<span style="white-space:pre">	</span>private int x,y;
}
class ErrConst extends Exception
{}
public class Except1
{
<span style="white-space:pre">	</span>public static void main(String args[])
<span style="white-space:pre">	</span>{
<span style="white-space:pre">		</span>try
<span style="white-space:pre">		</span>{
<span style="white-space:pre">			</span>Point a= new Point(1,4);
<span style="white-space:pre">			</span>a.affiche();
<span style="white-space:pre">			</span>a=new Point(-3,5);
<span style="white-space:pre">			</span>a.affiche();
<span style="white-space:pre">		</span>}
<span style="white-space:pre">		</span>catch(ErrConst e)
<span style="white-space:pre">		</span>{
<span style="white-space:pre">			</span>System.out.println("Erreur construction");
<span style="white-space:pre">			</span>System.exit(-1);
<span style="white-space:pre">		</span>}
<span style="white-space:pre">	</span>}
}




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值