Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Java™ How to Program, 9/e © Copyright 1992-2012 by Pearson Education, Inc. All Rights Reserved. © Copyright 1992-2012 by Pearson Education, Inc. All Rights Reserved. © Copyright 1992-2012 by Pearson Education, Inc. All Rights Reserved. © Copyright 1992-2012 by Pearson Education, Inc. All Rights Reserved. © Copyright 1992-2012 by Pearson Education, Inc. All Rights Reserved. © Copyright 1992-2012 by Pearson Education, Inc. All Rights Reserved. © Copyright 1992-2012 by Pearson Education, Inc. All Rights Reserved. printf method PDF © Copyright 1992-2012 by Pearson Education, Inc. All Rights Reserved. © Copyright 1992-2012 by Pearson Education, Inc. All Rights Reserved. Package Class java.util Scanner Scanner <variable> = new Scanner( System.in ); Scanner input = new Scanner( System.in ); Strings next( ) nextLine( ) String s; Numbers nextInt( ) nextDouble( ) Test for Input hasNext( ) int x, y; s = input.nextLine(); x = input.nextInt(); y = input.nextDouble(); © Copyright 1992-2012 by Pearson Education, Inc. All Rights Reserved. © Copyright 1992-2012 by Pearson Education, Inc. All Rights Reserved. © Copyright 1992-2012 by Pearson Education, Inc. All Rights Reserved. import statement fully qualified name (FQN) Java hierarchy: package class / classes global variables methods statements © Copyright 1992-2012 by Pearson Education, Inc. All Rights Reserved. Package java.lang Frequently uses classes System System.out, System.in, System.exit( ) String String name, String.format( ) Math Math.PI, Math.pow( ), Math.max( ) Double Double.parseDouble( ) Integer Integer.parseInt( ) © Copyright 1992-2012 by Pearson Education, Inc. All Rights Reserved. Operators (next slide) unary - (minus sign) binary =, +, -, *, / trinary ? : (conditional operator) Operands © Copyright 1992-2012 by Pearson Education, Inc. All Rights Reserved. Expressions Statements Assignment LHS variable RHS expression literal named constant ( keyword final ) String/Arithmetic expression © Copyright 1992-2012 by Pearson Education, Inc. All Rights Reserved. © Copyright 1992-2012 by Pearson Education, Inc. All Rights Reserved. Rules of operator precedence Multiplication, division and remainder operations are applied first. If an expression contains several such operations, they are applied from left to right. Multiplication, division and remainder operators have the same level of precedence. Addition and subtraction operations are applied next. If an expression contains several such operations, the operators are applied from left to right. Addition and subtraction operators have the same level of precedence. When we say that operators are applied from left to right, we are referring to their associativity. Some operators associate from right to left. Complete precedence chart is included in Appendix A. © Copyright 1992-2012 by Pearson Education, Inc. All Rights Reserved. © Copyright 1992-2012 by Pearson Education, Inc. All Rights Reserved. Condition Selection control structure if statement switch statement Relational operators Equality operators (next slide) © Copyright 1992-2012 by Pearson Education, Inc. All Rights Reserved. © Copyright 1992-2012 by Pearson Education, Inc. All Rights Reserved. © Copyright 1992-2012 by Pearson Education, Inc. All Rights Reserved. Additional Topics (if time permits) Strings Methods © Copyright 1992-2012 by Pearson Education, Inc. All Rights Reserved.