java x%y 2_JAVA 程序员培训 -2

1JAVA-2

if,else,for

,,equalsUser ArrayList add(Objecto) HashMap put(Objectkey, Objectvalue) object

if, switch,for,whiledobreakcontinue

java .Java:1)2) 3)1. 2.:

4.,booleanfalse all reference types---null.

.1 +-*/%x%yxy++ -- (++ --)----class Test {public static void main(String[] args) { int i=0; System.out.println(i); System.out.println(i++); System.out.println(++i); System.out.println(i);}}

2

,>>>,&,|,^,~ >, 00,11>>>

.

3 >,>=,

1ifelse 2if ,else if ,else 3switchswitch(byte,short,int,char){ case 1: 1break case 2: 2break default: nbreak } long

.

Exercisepublic class IfElse{public static void main(String args[]){if(odd(5))System.out.println(odd);elseSystem.out.println(Even);}public static int odd(int x){return x%2;}}What is the result?A. The output is odd; B. The output is even;C.An error on line 3 causes compilation to fail D.An error on line 8 causes compilation to fail

1.for()// { }2.while() {}3.do{ }while();

. Point p[] char c[]

c=new char[5]( 5)

,. :

int a[]={12345} String s[]={abcdef} =>String s[]={new String(abc), new String(def)};

.(inheritance)1.A is a BB has a Aextendsis a class A extends B A(is a B

(,,)

override

1)

2)

3).

.this

class Dot{ private int x,y,z; public Dot (int xint yint z){ this.x=x; this.y=y; this.z=z; }}

java.io.File.public File(String path)---pathFile pathFile

261. java: Error () Exception(,,)2. 8-13 Throwable 1.f.createNewFile();2.catchException

27 3. 8-15NullPointerException ArrayIndexOutOfBoundsExceptionIOException. File

28.try-catch-finally : try{ unsafe;() }catch( e) {//.; } finally{ ; }

29:try{unsafe(); T1;}catch(IOException e) { T2;}finally {T3;} T4;

31 trycatchmain

.

--,,1..2.:String userName;3..:public void getUserName(){}4.settergetter.

-- equalsequalsStringintboolean

3-- .String userName=defu;:.(.)//API

4--ArrayListHashMap

ArrayList

ArrayListimport java.util.*;class ArrayListTest {public static void main(String[] args) {ArrayList al=new ArrayList();al.add("FistElement");al.add("SecondElement");al.add("ThirdElement");for(int i=0;i

HashMapkeyvalueput(Object key, Object value)get(Object key) null

HashMappublic class FileTest {public static void main(String[] args) throws IOException {HashMap map = new HashMap();map.put("1","cheche");System.out.println(map.get("1"));}}

12345679131417242637382627282931

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值