CS1400

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

Java Mathematical Operators

*, /, % multiplication, division, modulo +, - addition and subtraction

Increment/Decrement Operators

++/--

.class vs. .java

.java-Source code, contains classes, has 1 public class, the filename is the same as public class .class-bytecode files, created whenever class is created in .java, virtual machine code

Loops

A loop statement allows us to execute a statement or group of statements multiple times and following is the general form of a loop statement in most of the programming languages while loop Repeats a statement or group of statements while a given condition is true. It tests the condition before executing the loop body. for loop Execute a sequence of statements multiple times and abbreviates the code that manages the loop variable. do...while loop Like a while statement, except that it tests the condition at the end of the loop body.

Legal Identifiers in Java

Begins with letter, including unicode letters Subsequent characters must be letters and digits Cannot contain operators like *, +, -, / etc Although $ is legal, it should be avoided Cannot be a reserved/keyword Are case sensitive Are unlimited in length

Java Convention

Case Sensitivity − Java is case sensitive, which means identifier Hello and hello would have different meaning in Java. Class Names − For all class names the first letter should be in Upper Case. If several words are used to form a name of the class, each inner word's first letter should be in Upper Case. Example: class MyFirstJavaClass Method Names − All method names should start with a Lower Case letter. If several words are used to form the name of the method, then each inner word's first letter should be in Upper Case. Example: public void myMethodName() Program File Name − Name of the program file should exactly match the class name. When saving the file, you should save it using the class name (Remember Java is case sensitive) and append '.java' to the end of the name (if the file name and the class name do not match, your program will not compile). Example: Assume 'MyFirstJavaProgram' is the class name. Then the file should be saved as 'MyFirstJavaProgram.java' public static void main(String args[]) − Java program processing starts from the main() method which is a mandatory part of every Java program.

Variable Types

Local Variables Class Variables (Static Variables) Instance Variables (Non-static Variables)

Pseudocode / Flowcharts

Pseudocode is an artificial and informal language that helps programmers develop algorithms. Pseudocode is a "text-based" detail (algorithmic) design tool. The rules of Pseudocode are reasonably straightforward. All statements showing "dependency" are to be indented.

== vs. .equals() in Java

String comparison is a common scenario of using both == and equals method. Since java.lang.String class override equals method, It return true if two String object contains same content but == will only return true if two references are pointing to same object.

Concatenation

concatenate Strings using the + operator: System.out.println("Your number is " + theNumber + "!"); string1.concat(string2);

String Methods

java.lang.string .equals(" ") .equalsIgnoreCase(" ") .length( ) .substring( , )

Compilers vs. Interpreters

source code ( .java files) is compiled into bytecode ( .class files) that is then interpreted by a Java Virtual Machine (also known as a JVM) for execution (the JVM can do further optimization but this is anoher story)


Kaugnay na mga set ng pag-aaral

BCH480 All quizzes/Test Questions

View Set

ATI Learning System RN 2.0 | Pharmacology Final Practice

View Set

Chapters 4-5 Learn Smart; Biomechanics

View Set

Virginia Life & Health Study Guide #1

View Set

FINA final conceptual questions from all

View Set

ch two: beginnings of english america

View Set

Real Bis: VA Law and Regulations - Chapter 5

View Set

UCCS Basic Health Assessment Chap. 10

View Set