Java for IOI.

Slides:



Advertisements
Similar presentations
Java Review Interface, Casting, Generics, Iterator.
Advertisements

Lab Information Security Using Java (Review) Lab#0 Omaima Al-Matrafi.
Lab#1 (14/3/1431h) Introduction To java programming cs425
George Blank University Lecturer. CS 602 Java and the Web Object Oriented Software Development Using Java Chapter 4.
CS 206 Introduction to Computer Science II 01 / 21 / 2009 Instructor: Michael Eckmann.
Chapter 3b Standard Input and Output Sample Development.
Java Data Types  Everything is an Object  Except Primitive Data Types  For efficiency  Platform independent  Portable  “slow”  Objects are often.
Lecture 1: Overview of Java. What is java? Developed by Sun Microsystems (James Gosling) A general-purpose object-oriented language Based on C/C++ Designed.
CSE373 Optional Section Java Collections 11/12/2013 Luyi Lu.
JAVA v.s. C++ Programming Language Comparison By LI LU SAMMY CHU By LI LU SAMMY CHU.
CIS 068 JAVA vs. C++ Main Differences. CIS 068 JAVA vs C++ Java is (an interpreted) write once, run anywhere language. –The biggest potential stumbling.
16 - Generics. 2 NOEA2009Java-kursus – Generics ”Generic” Programming in C#/Java (as it was until Summer 2005) All classes inherit from Object So we can.
Files and Streams. Java I/O File I/O I/O streams provide data input/output solutions to the programs. A stream can represent many different kinds of sources.
P Object type and wrapper classes p Object methods p Generic classes p Interfaces and iterators Generic Programming Data Structures and Other Objects Using.
1 Java Console I/O Introduction. 2 Java I/O You may have noticed that all the I/O that we have done has been output The reasons –Java I/O is based on.
1 Module Objective & Outline Module Objective: After completing this Module, you will be able to, appreciate java as a programming language, write java.
Algorithm Programming Bar-Ilan University תשס"ח by Moshe Fresko.
Generics in.NET and C# Generics. ”Generic” Programming in C#/Java (as it was until Summer 2005) All classes inherit from Object So we can apply polymorphism.
Introduction and Features of Java. What is java? Developed by Sun Microsystems (James Gosling) A general-purpose object-oriented language Based on C/C++
Java means Coffee Java Coffee Beans The name “JAVA” was taken from a cup of coffee.
Basics of Java IMPORTANT: Read Chap 1-6 of How to think like a… Lecture 3.
1 Object Oriented Programming Lecture IX Some notes on Java Performance with aspects on execution time and memory consumption.
Netprog: Java Intro1 Crash Course in Java. Netprog: Java Intro2 Why Java? Network Programming in Java is very different than in C/C++ –much more language.
Programming for Beginners Martin Nelson Elizabeth FitzGerald Lecture 15: More-Advanced Concepts.
Introduction to Object Oriented Programming CMSC 331.
Java 5 Part 1 CSE301 University of Sunderland Harry Erwin, PhD.
Parts of JAVA 1www.gowreeswar.com. Features of JAVA 2www.gowreeswar.com.
Java Basics.  To checkout, use: svn co scb07f12/UTORid  Before starting coding always use: svn update.
Java Basics Opening Discussion zWhat did we talk about last class? zWhat are the basic constructs in the programming languages you are familiar.
CSC 1051 M.A. Papalaskari, Villanova University Everyday objects: Strings and Wrappers CSC 1051 – Data Structures and Algorithms I Dr. Mary-Angela Papalaskari.
Duke CPS From C++ to Java l Java history: Oak, toaster-ovens, internet language, panacea l What it is ä O-O language, not a hybrid (cf. C++)
1.Net programmingGenericsNOEA / 2009 Generics 11. Generics in.NET and C#
Java Software Solutions Foundations of Program Design Sixth Edition by Lewis & Loftus Chapter 3: Using Classes and Objects Coming up: Creating Objects.
Duke CPS Java: make it run, make it right, make it fast (see Byte, May 1998, for more details) l “Java isn’t fast enough for ‘real’ applications”
Know Your Java. Java is special Java source code Byte code/ native code Object code on windows Object code on Dos Object code on Lynux.
“Unboxing” means taking an Integer object and assigning its value to a primitive int. This is done using the.intValue( ) method. Example; Integer z = new.
 It is a pure oops language and a high level language.  It was developed at sun microsystems by James Gosling.
Keerthi Nelaturu Url: site.uottawa.ca/~knela006
CIS 068 JAVA vs. C++ Main Differences CIS 068.
Using the Java Collection Libraries COMP 103 # T2
Variables in Java A variable holds either
Computer Organization and Design Pointers, Arrays and Strings in C
JAVA MULTIPLE CHOICE QUESTION.
Intro to ETEC Java.
Before You Begin Nahla Abuel-ola /WIT.
Review of Java … or maybe not.
CS240: Advanced Programming Concepts
Topic: Difference b/w JDK, JRE, JIT, JVM
Exercise on Java Basics
Dialogues and Wrapper Classes
CHAPTER 5 JAVA FILE INPUT/OUTPUT
Computer Programming Methodology Input and While Loop
Java Review: Reference Types
Java Virtual Machine Complete subject details are available at:
Overview of Hadoop MapReduce MapReduce is a soft work framework for easily writing applications which process vast amounts of.
Going from C++ to Java Jayden Navarro.
Parallel Programming in Contemporary Programming Languages (Part 2)
Exercise on Java Basics
CSc 453 Interpreters & Interpretation
CMSC 202 ArrayList Aug 9, 2007.
Unit 6 Working with files. Unit 6 Working with files.
Object-Oriented Software Engineering
Arrays and Collections
Object-Oriented Programming Paradigm
Welcome to CSE 143! Go to pollev.com/cse143.
(Computer fundamental Lab)
CS2011 Introduction to Programming I Strings
Creating and Modifying Text part 3
Outline Creating Objects The String Class The Random and Math Classes
Subtype Substitution Principle
Presentation transcript:

Java for IOI

Java vs C++ Very good IDE support Advantages Disadvantages Very good IDE support Powerful debugger and exception system Quick documentation Zero pointer shenanigans Verbose Slower than C++ Garbage collection overhead No/difficult low-level control

How Java works (and why you should care) A native program – the JVM – starts up and reads your compiled Java program The JVM has 2 jobs: Recompile the Java bytecode into native machine code (JIT) Perform maintenance tasks in the background (mostly memory management)

Java’s design Designed for enterprise – very formal and flexible Everything is classes and objects There are no pointers For speed in Java: Avoid creating new objects (when we really don’t need to) Avoid ‘disposing’ objects (when we really don’t need to)

Strings are immutable Don’t append to Strings in a loop – this creates a new String every time Use StringBuilder

Avoid the ‘primitive wrappers’ Integer, Double, etc. instead of int, double 1 instance per value*! But… generics can only use primitive wrapper classes Use arrays of primitives, or make your own data structures if really necessary array > ArrayList > LinkedList

I/O in Java Do not use Scanner! Use BufferedReader And use StringTokeniser for multiple lines .split() is about 2x slower And then Integer.parseInt() or double.parseDouble() etc. to convert the Strings For output, System.out.print() works fine (buffered internally)

Other notes Check out the methods in the primitive classes Integer, Double, Collections, Arrays Various utilities for sorting, type conversions, etc. Implement ‘comparable’ in your classes for easy sorting Keep everything in one file Append ‘static’ to everything Don’t use packages You can use inner classes Don’t use exceptions for logic