Java and C++ Transitioning. A simple example public class HelloWorldApp { public static void main(String[] args) { //Display the string. System.out.println("Hello.

Slides:



Advertisements
Similar presentations
CPSC 441 TUTORIAL – JANUARY 16, 2012 TA: MARYAM ELAHI INTRODUCTION TO C.
Advertisements

INHERITANCE BASICS Reusability is achieved by INHERITANCE
Your First Java Program: HelloWorld.java
Java Intro. A First Java Program //The Hello, World! program in Java public class Hello { public static void main(String[] args) { System.out.println("Hello,
BASIC JAVA. Hello World n // Hello world program public class MyFirstJavaProgram { public static void main(String args[]) { char c = 'H'; String s =
Datalogi A 1: 8/9. Book: Cay Horstmann: Big Java or Java Consepts.
Slide 1 of 40. Lecture A The Java Programming Language Invented 1995 by James Gosling at Sun Microsystems. Based on previous languages: C, C++, Objective-C,
Fundamental Programming Structures in Java: Comments, Data Types, Variables, Assignments, Operators.
Computer Science A 1: 3/2. Course plan Introduction to programming Basic concepts of typical programming languages. Tools: compiler, editor, integrated.
Java CourseWinter 2009/10. Introduction Object oriented, imperative programming language. Developed: Inspired by C++ programming language.
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.
Command line arguments. – main can take two arguments conventionally called argc and argv. – Information regarding command line arguments are passed to.
Programming in Java; Instructor:Moorthy Introduction, Objects, Classes, Libraries1 Programming in Java Introduction.
+ Java vs. Javascript Jessi Style. + Java Compiled Can stand on its own Written once, run anywhere Two-stage debugging Java is an Object Oriented Programming.
Hello AP Computer Science!. What are some of the things that you have used computers for?
2.2 Information on Program Appearance and Printing.
LESSON 2 CREATING A JAVA APPLICATION JAVA PROGRAMMING Compiled By: Edwin O. Okech [Tutor, Amoud University]
By Noorez Kassam Welcome to JNI. Why use JNI ? 1. You already have significantly large and tricky code written in another language and you would rather.
CIS 644 Aug. 25, 1999 tour of Java. First … about the media lectures… we are experimenting with the media format please give feedback.
May 9, 2002Serguei A. Mokhov, 1 Kickstart Intro to Java Part I COMP346/ Operating Systems Revision 1.6 February 9, 2004.
POS 406 Java Technology And Beginning Java Code
Java means Coffee Java Coffee Beans The name “JAVA” was taken from a cup of coffee.
Programming Fundamentals 2: Simple/ F II Objectives – –give some simple examples of Java applications and one applet 2. Simple Java.
Mixing integer and floating point numbers in an arithmetic operation.
JAVA Programming “When you are willing to make sacrifices for a great cause, you will never be alone.” Instructor: รัฐภูมิ เถื่อนถนอม
A Look at Java. Categorize Java Which paradigm? Which paradigm? Scripting? Scripting? Declarative or procedural? Declarative or procedural? Which generation?
Core Java Introduction Byju Veedu Ness Technologies httpdownload.oracle.com/javase/tutorial/getStarted/intro/definition.html.
Overview of Java CSCI 392 Day One. Running C code vs Java code C Source Code C Compiler Object File (machine code) Library Files Linker Executable File.
1 Basic Java Constructs and Data Types – Nuts and Bolts Looking into Specific Differences and Enhancements in Java compared to C.
Lab 01-2 Objectives:  Writing a Java program.  How to send output to the command line console.  Learn about escape sequences.  Learn how to compile,
CSI 3125, Preliminaries, page 1 Compiling the Program.
Functions & Pointers in C Jordan Erenrich
ITEC 320 Lecture 9 Nested records / Packages. Review Project ?’s Records Exam 1 next Friday.
Developed at Sun Microsystems in 1991 James Gosling, initially named “OAK” Formally announced java in 1995 Object oriented and cant write procedural.
CSE 1341 Honors Note Set 2 1. Overview  Java vs. C++  Functions in C++  First Programming Packet  Development Environment 2.
Packages. The main feature of OOP is its ability to support the reuse of code: –Extending the classes –Extending interfaces The features in basic form.
CPRG 215 Introduction to Object-Oriented Programming with Java Module 1-Introduction to Java Topic 1.3 Write Your First Java Program Produced by Harvey.
Modules (Methods) Functions and Procedures Parameters...Output.
CS001 Introduction to Programming Day 6 Sujana Jyothi
Computer Science A 1. Course plan Introduction to programming Basic concepts of typical programming languages. Tools: compiler, editor, integrated editor,
Methods What is a method? Main Method the main method is where a stand alone Java program normally begins execution common compile error, trying.
JAVA METHODS (FUNCTIONS). Why are they called methods? Java is a strictly object-oriented programming language Methods are functions inside of objects.
Processing == Java + Extra Utilities Processing Adds: – Drawing functions – Text and font manipulations – Image and video – 3D transformations – Keyboard.
Object Oriented Programming Lecture 2: BallWorld.
1 Stack and Heap. 2 “Stack” Stack – a linear data structure in which items are added and removed in last-in, first-out order. Definition: context – the.
Introduction to java (class and object). Programming languages: –Easier to understand than CPU instructions –Needs to be translated for the CPU to understand.
Java Methods and Applications CSIS 3701: Advanced Object Oriented Programming.
Computer Programming Your First Java Program: HelloWorld.java.
Overview 4 major memory segments Key differences from Java stack
Examples of Classes & Objects
Command line arguments
Intro to Java.
Going from C++ to Java Jayden Navarro.
Java Intro III.1 (Fr Feb 23).
Overview 4 major memory segments Key differences from Java stack
An Introduction to Java – Part I, language basics
Classes & Objects: Examples
Tonga Institute of Higher Education
Java so far Week 7.
Java Intro.
class PrintOnetoTen { public static void main(String args[]) {
A Java Application public class Hello { public static void main(String [] args) { System.out.println("Hello, World!"); } } public class.
A Java Application public class Hello { public static void main(String [] args) { System.out.println("Hello, World!"); } } public class.
Fundamental OOP Programming Structures in Java: Comments, Data Types, Variables, Assignments, Operators.
Developing Java Applications with NetBeans
In this class, we will cover:
Developing Java Applications with NetBeans
F II 2. Simple Java Programs Objectives
Introduction to java Part I By Shenglan Zhang.
ENERGY 211 / CME 211 Lecture 29 December 3, 2008.
Presentation transcript:

Java and C++ Transitioning

A simple example public class HelloWorldApp { public static void main(String[] args) { //Display the string. System.out.println("Hello World!"); } } #include void main (int argc, char* argv[]) { cout << “Hello World”); } JAVA C++

Everything is a class in java public class HelloWorldApp { public static void main(String[] args) { //Display the string. System.out.println("Hello World!"); } } #include void main (int argc, char* argv[]) { cout << “Hello World”); } JAVA C++

static declarations public class HelloWorldApp { public static void main(String[] args) { //Display the string. System.out.println("Hello World!"); } } #include void main (int argc, char* argv[]) { cout << “Hello World”); } JAVA C++

static Declarations Used in class specifications Also used in other areas (ambiguity) –Must consider context One instance for ALL objects public class A { int x; static int y; void B(){…} static void C(){…} } A1 = new A(); A2 = new A(); A3 = new A(); 3 x values 1 y value Must declare an instance Of A to call B e.g. A1.B(); Use class to call C e.g. A.C(); System.out.println…

Different I/O procedures public class HelloWorldApp { public static void main(String[] args) { //Display the string. System.out.println("Hello World!"); } } #include void main (int argc, char* argv[]) { cout << “Hello World”); } JAVA C++

Command line parameters public class HelloWorldApp { public static void main(String[] args) { //Display the string. System.out.println("Hello World!"); } } #include void main (int argc, char* argv[]) { cout << “Hello World”); } JAVA C++

No include statements in java public class HelloWorldApp { public static void main(String[] args) { //Display the string. System.out.println("Hello World!"); } } #include void main (int argc, char* argv[]) { cout << “Hello World”); } JAVA C++

File naming public class HelloWorldApp { public static void main(String[] args) { //Display the string. System.out.println("Hello World!"); } } #include void main (int argc, char* argv[]) { cout << “Hello World”); } JAVA C++ HelloWorldApp.java Must be named: Anything.cpp Named ANYTHING:

File Organization JAVA C++ MainFile.java ClassA.javaClassB.java Main routine ClassA ClassB OR MainFile.cpp ClassA.cpp ClassB.java

No explicit pointers public class A { int x,y; A(){x=0;y=0;} public void printit(){…} } public class HelloWorldApp { public static void main(String[] args) { A A1, A2; A1 = new A(); A2 = new A(); A1.printit() } JAVA

Pointers in c++ class A { int x,y; A(){x=0;y=0;} public void printit(){…} } void main() { A* A1, A2; A1 = new A(); A2 = new A(); A1->printit(); } C++

Accessing Libraries C++ –Uses include –Requires compilation and explicit listing of files to be compiled/linked Java –No include/headers –Libraries grouped in packages –List libraries to be used in import –Automatically incorporates files from packages without explicit listing other than import –More notes on packages and import later