210 likes | 220 Views
Explore the history, features, and development of Java programming, including key concepts like objects, classes, and methods. Learn about the Java Development Kits (JDK) and how Java enables code reusability and efficiency.
E N D
Computer Programming with JAVA Chapter 1 Introduction and A Taste of Java
Contents • Object-Oriented Programming • History of the Java Language • A First Java Program • Compiling and Running a Java Program
Object-Oriented Programming • What are Objects? • All things around us • Ability to perform actions • Status • OOP (or Paradigm) • A programming methodology (paradigm) that views a program as this sort of world consisting of objects that interact with each other by means of actions. • Methods, data
Object-Oriented Programming (1) • Objects • A program construction that has data associated with it and that can perform certain actions • Methods • The actions performed by objects • Class • A type or kind of object • What is difference between OOP and Procedural-Oriented Programming? • Code reusability • Efficiency
A Brief History of the Java Language • A brief history of the Java • 1990: • Gosling, J. and Naughton, P. • 1991: Green Project • *7 system by 1st Person Inc. named by Oak • Research settop box and VOD with Green (O.S.) • Gosling, J., designing a programming language for home appliances • Java byte code: Intermediate language for inexpensive portability • 1991: WWW, 1992: Web browser
A Brief History of the Java Language (1) • 1994: • NCSA Mosaic, WebRunner (HotJava) browser, applet • 1995: • adapted for New technology for WWW • Netscape and MS agreed license of Java • 1996: • Java 1.0.2
A Taste of Java • Features • JAVA : A simple, Object-Oriented, distributed, interpreted, robust, secure, machine-independent (portable), high-performance, multi-thread, and dynamic language • Simple : No operator overloading, multiple inheritance, memory management, header file, structure, union, enumeration, pointer arithmetic, template, preprocessing, user-defined type conversion. • Object-Oriented • Distributed : WWW • Robust : no memory management, exception handling, error checking in compile-time.
A Taste of Java (1) • secure : public-key, restricted client resource access • 자바 애플릿은 클라이언트 내의 디스크를 read/write할 수 없다. • 자바 애플릿은 클라이언트의 다른 응용프로그램을 실행시킬 수 없다. • 자바 애플릿은 다운로드된 서버 외에는 접속할 수 없다. • Machine-Independent (portable) • “Write Once Run Everywhere” • Compiled : compiled into byte code • Interpreted : bytecodes are interpreted by Java Virtual Machine • Multi-Thread
Server Client Java Applet Bytecode verifier Java Compiler Class loader Java Run-time interpreter Just-in- Time Compiler Java Bytecodes Java Bytecodes Applet Store Hardware platform Security model in Java
Machine-independent Property Pentium Pentium executable code Source code Mac Mac executable code Unix Unix executable Pentium Pentium Java Interpreter Source code Java Bytecodes Mac Mac Java Interpreter Unix Unix Java Interpreter
A Taste of Java (2) • Types of Java program • Applet • To be sent to another (remote) location on the WWW and run there. • Application • Running on your (local) computer. main() • Byte Code • Executable code in the Java • Machine-independent, neutral, intermediate code
A Taste of Java (3) • Difference between C++ and Java
Java Development Kit • JDK • contains the software and tools that developers need to compile, debug, and run applets and applications written using the Java programming language. • JDK 1.0 • Just reflect the feature of language itself andthe one of Applet • Sun didn’t pass through the alpha, beta version, and just were intended on displaying the bug-modified version • problem : huge bugs and insufficient GUI
Java Development Kit (1) • JDK 1.1 • Event-driven model, light component framework • JDBC, RMI, JavaBeans, Globalization, LocalizationAPI • Object Serialization • Servlet Api, Enterprise JavaBeans • 자바가 Server측에 수용되는데 밑거름이 됨
Java Development Kit (2) • JDK 1.2 • JDBC, RMI등의 기반 API들을 개선 • 2-Dimension Imagiing과 Printing, GUI component Security Model • CORBA의 지원(org.*) • 주로 client측의 S/W를 위한 API완성
Java Development Kit (3) • Java 2 Platform • Java 1.2의 정식 버젼 • API관련 • Swing, 2D API, drag&drop API, JFC • Security관련 • Policy-Based Access Control • 프로그래밍 관련 • 강력한 자료구조코딩을 위한 collection framework • 참조객체지원 • Reflection과 Serialization에 대한 성능 개선 • HotSpot은 포함되지 않음
publicclass FirstProgram{ publicstaticvoid main(String[] args){ System.out.println("Hello out there."); System.out.println("Want to talk some more?"); System.out.println("Answer y for yes or n for no."); char answerLetter; answerLetter = SavitchIn.readLineNonwhiteChar(); if(answerLetter == 'y') System.out.println("Nice weather we are having."); System.out.println("Good-bye"); System.out.println("Press enter key to end program."); String junk; junk = SavitchIn.readLine(); } } Display 1.4: A Simple Java Program
Spelling Rules • Identifier • A name in a programming language • e.g.) a class or variable name • Rules • It must consist entirely of letters, digits (0-9), and underscore character (_) • The first character cannot be a digit • No identifier can contain a space or any other character such as a period or an *. • There is no limit to the length of a name • Case-Sensitive • e.g.) mystuff, myStuff, Mystuff
Spelling Rules (1) • Unicode • It can include characters that are used in other languages • It must avoid the reserved words (or keywords) and built-in classes and their member
Compiling and Running a Java Program • Compiling • javac MyClass.java • Running • java MyClass
Java source (.java) (FirstProgram.java) Java Compiler (javac) Java Bytecodes (FirstProgram.class) Java Interpreter (java) Display 1.3: Compiling and Running a Java Program