L3. Necessary Java Programming Techniques

Slides:



Advertisements
Similar presentations
I/O Basics 12 January 2014Smitha N. Pai, CSE Dept.1.
Advertisements

Computer Programming Lab(7).
MOD III. Input / Output Streams Byte streams Programs use byte streams to perform input and output of 8-bit bytes. This Stream handles the 8-bit.
Computer Programming Lab 8.
L2. Necessary Java Programming Techniques (Vector) Packages  Java.util import Java.util.*; Classes  Vector Interfaces  Enumeration Java API.
1 Repetition structures Overview while statement for statement do while statement.
Random (1) Random class contains a method to generate random numbers of integer and double type Note: before using Random class, you should add following.
Reading Information From the User Making your Programs Interactive.
Programming in Java; Instructor:Alok Mehta Objects, Classes, Program Constructs1 Programming in Java Objects, Classes, Program Constructs.
Strings and File I/O. Strings Java String objects are immutable Common methods include: –boolean equalsIgnoreCase(String str) –String toLowerCase() –String.
Problem Solving #3: JVM ICS Outline Review of Key Topics Review of Key Topics Problem 1 Problem 1 Problem 2 Problem 2 Problem 3 Problem 3 Problem.
Java I/O – what does it include? Command line user interface –Initial arguments to main program –System.in and System.out GUI Hardware –Disk drives ->
COMP 14 Introduction to Programming Miguel A. Otaduy May 14, 2004.
Java Review 2. The Agenda The following topics were highlighted to me as issues: –File IO (Rem) –Wrappers (Rem) –Interfaces (Rem) –Asymptotic Notation.
Chapter 3b Standard Input and Output Sample Development.
10 ThinkOfANumber program1July ThinkOfANumber program CE : Fundamental Programming Techniques.
Reading Input -- the Keyboard Class The Keyboard class is NOT part of the Java standard class library The Keyboard class is in package cs1. It provides.
1 Scanner objects. 2 Interactive programs We have written programs that print console output. It is also possible to read input from the console.  The.
Computer Programming Lab(5).
Io package as Java’s basic I/O system continue’d.
1 Course Lectures Available on line:
CSI 1390: Introduction to Computers TA: Tapu Kumar Ghose Office: STE 5014
Console Input. So far… All the inputs for our programs have been hard-coded in the main method or inputted using the dialog boxes of BlueJ It’s time to.
Chapter 5: Preparing Java Programs 1 Chapter 5 Preparing Java Programs.
Basic Java Programming CSCI 392 Week Two. Stuff that is the same as C++ for loops and while loops for (int i=0; i
OOP (Java): Simple/ OOP (Java) Objectives – –give some simple examples of Java applications and one applet 2. Simple Java Programs Semester.
Introduction to Programming Prof. Rommel Anthony Palomino Department of Computer Science and Information Technology Spring 2011.
Input & Output In Java. Input & Output It is very complicated for a computer to show how information is processed. Although a computer is very good at.
Java Arrays …………. Java Arrays …………. * arrays are objects in Java * arrays are objects in Java * an array variable is a reference * an array variable is.
CIS 260: App Dev I. 2 Programs and Programming n Program  A sequence of steps designed to accomplish a task n Program design  A detailed _____ for implementing.
JAVA PROGRAMMING BASICS CHAPTER 2. History of Java Begin with project Green in 1991 founded by Patrick Noughton, Mike Sheridan and James Gosling who worked.
Programming Fundamentals 2: Simple/ F II Objectives – –give some simple examples of Java applications and one applet 2. Simple Java.
Recursive Problem 1 Write a java class named my_WordReverse using recursion. It takes a sentence and returns the sentence in reverse order. Note: Space.
Java 1.5 The New Java Mike Orsega Central Carolina CC.
Outline Character Strings Variables and Assignment Primitive Data Types Expressions Data Conversion Interactive Programs Graphics Applets Drawing Shapes.
CIS Intro to JAVA Lecture Notes Set 6 2-June-05.
CSI 3125, Preliminaries, page 1 Java I/O. CSI 3125, Preliminaries, page 2 Java I/O Java I/O (Input and Output) is used to process the input and produce.
I/O Basics 26 January Aside from print( ) and println( ), none of the I/O methods have been used significantly. The reason is simple: most real.
Packages. 9/04/2005 Copyright 2005, by the authors of these slides, and Ateneo de Manila University. All rights reserved L13: Layout Managers Slide 2.
CSCI 1100/1202 January 23, Class Methods Some methods can be invoked through the class name, instead of through an object of the class These methods.
 CSC111 Quick Revision. Problem Write a java code that read a string, then show a list of options to the user to select from them, where:  L to print.
import java.util.Scanner; class myCode { public static void main(String[] args) { Scanner input= new Scanner(System.in); int num1; System.out.println(“Enter.
Interactive Programs Programs that get input from the user 1 In PowerPoint, click on the speaker icon then click the "Play" button to hear the narration.
Input Characters from the Keyboard tMyn1 Input Characters from the Keyboard We have been using console output, but not console (keyboard) input. The main.
Copyright 2008 by Pearson Education Building Java Programs Chapter 3 Lecture 3-3: Interactive Programs w/ Scanner reading: self-check: #16-19.
Outline Creating Objects The String Class The Random and Math Classes Formatting Output Enumerated Types Wrapper Classes Components and Containers Images.
I/O in java and Revision. 2 I/O in Java Many packages and libraries associated with Java provide sophisticated ways to input and output information, e.g.:
CSC111 Quick Revision.
Introduction to programming in java
Strings and File I/O.
Chapter 6 More Conditionals and Loops
Maha AlSaif Maryam AlQattan
CS1101: Programming Methodology Recitation 7 – Exceptions
Interactive Standard Input/output
Objects, Classes, Program Constructs
Using Jsoup to Parse HTML
I/O Basics.
SELECTION STATEMENTS (1)
INPUT STATEMENTS GC 201.
Control Statement Examples
Yong Choi School of Business CSU, Bakersfield
Building Java Programs
L3. Necessary Java Programming Techniques
Using the Java Library API
L2. Necessary Java Programming Techniques
L2. Necessary Java Programming Techniques
Lecture Notes - Week 2 Lecture-1. Lecture Notes - Week 2 Lecture-1.
មជ្ឈមណ្ឌលកូរ៉េ សហ្វវែរ អេច អ ឌី
F II 2. Simple Java Programs Objectives
Presentation transcript:

L3. Necessary Java Programming Techniques Java API (Vector) Continue doing ex2 Packages  Java.util import Java.util.*; Classes  Vector Interfaces  Enumeration

An example of using class Vector Run Java applet => VectorTest.html Take a look at source code => VectorTest.java Exercise: 1. Understand and run the program. 2. Add a reverse button and it displays the elements in the vector in a reverse order.

Output: Optional exercise:   Enter lines of input, use quit to end the program.   apple   orange   banana   grape   lemon   quit   Number of lines: 5   Middle line: banana   Lines in reverse order:   Lines in reverse alphabetical order: Optional exercise: Write a java application program that uses Vector class and can output the result as shown in the right.

The program outline: import java.io.*; import java.util.*; public class ReverseLines { public static void main (String[] args) throws IOException { BufferedReader in = new BufferedReader (new InputStreamReader (System.in)); final String STOPPER = "quit"; Vector lines = new Vector(); System.out.println ("Enter lines of input, use " + STOPPER + " to end the program."); // Read in line of input until user enters stopping value. // Put each line of input into the vector. // your source code    // Print the lines in reverse order - step 4 in the handout. // Print the lines in reverse alphabetical order }