Java Programming - WordPress

2y ago
134 Views
22 Downloads
1.04 MB
174 Pages
Last View : Today
Last Download : 3m ago
Upload by : Rafael Ruffin
Transcription

Java Programming

Our AgendaIntroduction to OOPSWhat is Java?The building Blocks of Java-- JDKJava architectureThe java.lang. packageBasic program constructsApplets v/s ApplicationsCopyright 2005, Infosys TechnologiesLtd2

Agenda ContinuedThe Utilities in util packageUser interface & Event HandlingExceptions HandlingCopyright 2005, Infosys TechnologiesLtd3

Before the first Cup .Before we begin something on installation– Have jdk1.2.2 installed– you get an exe version– set path after installation– to test open a command window and type javac– if it gives a help for the command the installation is OKCopyright 2005, Infosys TechnologiesLtd4

Introducing to OOPSYou need to familiarize yourself with some terms like “Class”, “Object”,“Inheritance”, “Polymorphism” etc etc .The programming style that you use in C where importance is given forfunctions can be called as structured programmingImportance is given only to functionality, no importance is associatedwith the Data.Copyright 2005, Infosys TechnologiesLtd5

Class .Objects .What is a Class?– A class is a blueprint or prototype that defines the variables and the methodscommon to all objects of a certain kind.So what is an Object?– An object is a software bundle of related variables and methods. Softwareobjects are often used to model real-world objects you find in everyday life.Copyright 2005, Infosys TechnologiesLtd6

Representation of ObjectCopyright 2005, Infosys TechnologiesLtd7

The ObjectThe object diagrams show that the object's variables make up the center,or nucleus, of the objectMethods surround and hide the object's nucleus from other objects in theprogram. Packaging an object's variables within the protective custody ofits methods is called encapsulationCopyright 2005, Infosys TechnologiesLtd8

State & BehaviorThe functions are called methods and the variables attributesThe “value” of the attributes is called the state.Somebody calling a method on an object and the method gettingexecuted by making use of current state is invoking the behaviorCopyright 2005, Infosys TechnologiesLtd9

How do you write a classIn Java we use a key word class– A class is defined as followsclass Employ {String Name;//attributeint Age;//attribute//a behaviorvoid printDetails(){System.out.println(“Name is” Name);System.out.println(“Age is” Age);}}Copyright 2005, Infosys TechnologiesLtd10

InheritanceNow you have understood a Class let us look at what is inheritance.A class inherits state and behavior from its super-class. Inheritanceprovides a powerful and natural mechanism for organizing andstructuring software programs.Copyright 2005, Infosys TechnologiesLtd11

InheritanceHowever, subclasses are not limited to the state and behaviors providedto them by their superclass.Subclasses can add variables and methods to the ones they inherit fromthe superclass.Copyright 2005, Infosys TechnologiesLtd12

OverridingSubclasses can also override inherited methods and providespecialized implementations for those methods.You are not limited to just one layer of inheritance. The inheritancetree, or class hierarchy, can be as deep as needed.Methods and variables are inherited down through the levelsCopyright 2005, Infosys TechnologiesLtd13

InheritanceInheritance offers the following benefits: Subclasses provide specialized behaviors from the basis of common elementsprovided by the super classProgrammers can implement super-classes called abstract classes thatdefine "generic" behaviors.– The abstract superclass defines and may partially implement the behavior, butmuch of the class is undefined and unimplementedCopyright 2005, Infosys TechnologiesLtd14

What is Java?A language developed at Sun MicrosystemsA general-purpose languageHigh-level languageDeveloped initially for consumer devicesHelp in building a dynamic WebSupported today by most of the big players like IBM, Netscape, Oracle,Inprise etc.Copyright 2005, Infosys TechnologiesLtd15

Features Of JavaObject-orientedSimpleRobustSecureArchitecture Neutral / PortableMultithreadedDistributedCopyright 2005, Infosys TechnologiesLtd16

Java - The BasicsDraws features from OO languages like Smalltalk, C , AdaAn interpreted languageUses a virtual machine called Java Virtual Machine (JVM)A very exhaustive OO libraryCopyright 2005, Infosys TechnologiesLtd17

Hello WorldWe will have the source code firstType this into any text editorpublic class HelloWorldApp {public static void main(String[]args){System.out.println(“Hello World!”);}}Save this as HelloWorldApp.java (take care case matters .)Copyright 2005, Infosys TechnologiesLtd18

Some RulesThe name of the file must always be the name of the “public class”It is 100% case sensitiveYou can have only one public class in a file(i.e. in one .java file)Every “stand alone” Java program must have a public static void maindefined– it is the starting point of the program.Copyright 2005, Infosys TechnologiesLtd19

To CompileOpen a command promptGo to the directory you have saved your program.Type javac HelloWorldApp.java.– If it says bad command or file name set the path– If it does not say anything and get the prompt the compilation was successful.Copyright 2005, Infosys TechnologiesLtd20

To executeType in the command prompt“java HelloWorldApp”The resultCopyright 2005, Infosys TechnologiesLtd21

So How did this work .Copyright 2005, Infosys TechnologiesLtd22

Platform independence .Java is a language that is platform independent.A platform is the hardware or software environment in which a programrunsOnce compiled code will run on any platform without recompiling or anykind of modification.This is made possible by making use of a Java Virtual Machine a.k.a. JVMCopyright 2005, Infosys TechnologiesLtd23

Java Virtual MachineJVM can be considered as a processor purely implemented withsoftware.The .class file that is generated is the machine code of this processor.The interface that the JVM has to the .class file remains the sameirrespective of the underlying platform .This makes platform independence possibleCopyright 2005, Infosys TechnologiesLtd24

Platform independenceThe JVM interprets the .class file to the machine language of theunderlying platform .The underlying platform processes the commands given by the JVM andreturns the result back to JVM which displays it for you.Copyright 2005, Infosys TechnologiesLtd25

The life cycleThe Java programming language is unusual in that a program is bothcompiled and interpretedWith the compiler, first you translate a program into an intermediatelanguage called Java bytecodes-the platform-independent codesinterpreted by the interpreter on the Java platformCopyright 2005, Infosys TechnologiesLtd26

A Diagrammatic RepresentationCopyright 2005, Infosys TechnologiesLtd27

JDKJDK or Java Development Kit is a free software that can be used to writeand compile Java programs.Currently version 1.3 has been released but we will be using version 1.2.2It has lots of examples and the Standard Java Class Library also calledthe APICopyright 2005, Infosys TechnologiesLtd28

JDKWe will be making use of the Classes defined in the standard library bycreating objects or inheriting from those classes.We use the javac compiler provided with JDKWe have tools like javadoc, rmiregistry, appletviewer etc which we maymake use ofCopyright 2005, Infosys TechnologiesLtd29

The Java PlatformThe Java platform has two components: The Java Virtual Machine (Java VM) The Java Application Programming Interface (Java API)The Java API is a large collection of ready-made software componentsthat provide many useful capabilities, such as graphical user interface(GUI) widgets.Copyright 2005, Infosys TechnologiesLtd30

The Java DefinitionThe Java programming language is a high-level language that can becharacterized by all of the following buzzwords:Simple, Architecture-neutral, Object-oriented, Portable, Distributed, Highperformance, Interpreted, Multithreaded, Robust, Dynamic and SecureCopyright 2005, Infosys TechnologiesLtd31

Constituents of a ClassVariables or Data MembersConstructorsFunctions or MethodsClasses, also called Inner ClassesStartup function, if it is a starter classCopyright 2005, Infosys TechnologiesLtd32

Data TypesStrongly typed languageTwo types of variables– Primitive type– Reference type– null is a special typeReference types cannot be cast to primitive typesCopyright 2005, Infosys TechnologiesLtd33

Primitive Data Typesbyte Byte-length integershortShort integer8-bit two's complement16-bit two's complementint Integer 32-bit two's complementlong Long integer64-bit two's complement(real numbers)Copyright 2005, Infosys TechnologiesLtd34

Primitive Data TypesfloatSingle-precision floating point32-bit IEEE 754double Double-precision floating pointcharA single characterboolean64-bit IEEE 75416-bit Unicode characterA boolean value (true or false)falseCopyright 2005, Infosys TechnologiesLtd35true or

References .Arrays, classes, and interfaces are reference typesA reference is called a pointer, or a memory address in other languagesThe Java programming language does not support the explicit use ofaddresses like other languages doCopyright 2005, Infosys TechnologiesLtd36

Reference.Copyright 2005, Infosys TechnologiesLtd37

Access SpecifiersThere are four access specifiers:– public– private– “ ” - package– protectedCopyright 2005, Infosys TechnologiesLtd38

Access for TypesAccess specifiers could be used on classes in JavaAll classes belong to packages in Java“public” types are only accessible outside the packageprivate and protected specifier are invalid for classesCopyright 2005, Infosys TechnologiesLtd39

Modifiers in JavaAccess yright 2005, Infosys TechnologiesLtd40

“final” Modifier“final” modifier has a meaning based on its usageFor variable:– Primitives: read-only– Objects: reference is read-only– use all upper case lettersFor methods: no overridingFor classes: no inheritanceCopyright 2005, Infosys TechnologiesLtd41

“abstract” Modifier“abstract” modifier is used to defer an operationCannot be used for variablesFor methods: no implementationFor classes: no instantiationA concrete class can be made abstract by using the modifier for the classCopyright 2005, Infosys TechnologiesLtd42

Rules to FollowThe following cannot be marked with “abstract” modifier– Constructors– Static methods– Private methods– Methods marked with “final” modifierCopyright 2005, Infosys TechnologiesLtd43

“native” Modifier“native” modifier is used to indicate implementation of the method in anon-Java language, like C/C The library where the method is implemented should be loaded beforeinvoking native methods“synchronized” ModifierDiscussed in the module on threadingCopyright 2005, Infosys TechnologiesLtd44

VariablesThe Java programming language has two categories of data types:primitive and reference.A variable of primitive type contains a single value of the appropriate sizeand format for its type: a number, a character, or a boolean valueCopyright 2005, Infosys TechnologiesLtd45

Scope of variablesA variable's scope is the region of a program within which the variablecan be referred to by its simple name.Scope also determines when the system creates and destroys memoryfor the variableDon’t confuse Scope with VisibilityCopyright 2005, Infosys TechnologiesLtd46

Scope .Copyright 2005, Infosys TechnologiesLtd47

Member VariablesA member variable is a member of a class or an object.It is declared within a class but outside of any method or constructor.A member variable's scope is the entire declaration of the class.The declaration of a member needs to appear before it is usedCopyright 2005, Infosys TechnologiesLtd48

Local VariablesYou declare local variables within a block of codeThe scope of a local variable extends from its declaration to the end ofthe code block in which it was declaredCopyright 2005, Infosys TechnologiesLtd49

Parameter ScopeParameters are formal arguments to methods or constructors and areused to pass values into methods and constructors.The scope of a parameter is the entire method or constructor forwhich it is a parameter.Exception-handler parameters are similar to parameters but arearguments to an exception handler rather than to a method or aconstructorCopyright 2005, Infosys TechnologiesLtd50

Final variablesYou can declare a variable in any scope to be final .The value of a final variable cannot change after it has beeninitialized.Such variables are similar to constants in other programminglanguages.To declare a final variable, use the final keyword in the variabledeclaration before the type:Copyright 2005, Infosys TechnologiesLtdfinal int Var 0;51

VisibilityVisibility is set with an access modifierApplies only to member variables and determines whether the variablecan be used from outside of the class within which it is declared.The access modifiers are public, protected, private and default(whennone specified)The default scope is Package.Copyright 2005, Infosys TechnologiesLtd52

Public-PrivatePublic variables and methods are those which can be accessed from anywhere i.e. From the class, outside the class and outside the package.Private variables are those which can be accessed only within the class.They are not visible outside that class.Copyright 2005, Infosys TechnologiesLtd53

ProtectedProtected variables re those which are visible only inside the class andthe children classes of that class.If your class extends a base class then your derived class will be able toaccess the variables and methods of the base class that are declared asprotected( and public of course .)Copyright 2005, Infosys TechnologiesLtd54

Default ScopeThe default Scope i.e. if you don’t specify any access modifiers the scopeis package scope.It means that within the package the class is it will be accessible butoutside the package it is not accessible.Copyright 2005, Infosys TechnologiesLtd55

Class Member AccessPrivateFriendlyProtected PublicSame esCopyright 2005, Infosys TechnologiesLtd56

The syntax.Java follows exactly the syntax of C with some minor differences.A happy news -------THERE IS NO POINTERS IN JAVABut we have a concept called reference that we have discussed alreadyCopyright 2005, Infosys TechnologiesLtd57

Interfaces( Inheritance in Java ]Class AClass AClass BClass BClass CClass CAllowed in JavaNot Allowed in JavaCopyright 2005, Infosys TechnologiesLtd58

InterfaceFollowing are the code for the diagram in the slide shownbefore :ClassClassBBextendsextendsAA{{ClassClass CC extendsextendsAA, ,BB{{}}}}ClassClassCCextendsextendsBB{{}}The code written above isnot acceptable by JavaCopyright 2005, Infosys TechnologiesLtd59

Implementing Multiple Inheritance in JavaInter AInter BInter CClass E can inherit frominterface A, B and C inthe following manner :INTERFACEClass EClassClass EE implementsimplements A,A,B,B,CC{{. . . . . . . . . . . . .; ;}}Copyright 2005, Infosys TechnologiesLtd60

Another way of implementing multiple InheritanceClass AEXTENDSinter BInter CClass E can inherit fromclasses A,& implements Band C in another way asshown here :INTERFACEClass EClassClassEEextendsextendsAA implementsimplementsB,B,CC{{. . . . . . . . . . . . .; ;}}Copyright 2005, Infosys TechnologiesLtd61

Creating an interface classIn Java interfacing is donein the following manner :When the code is executedas given below,“myinterface”.class file willbe created in the ntadd(intx,x,intinty)y); ;}}When the code for interface is executed as given below :javac –d c:\JavaProgs\ myinterface . javaCopyright 2005, Infosys TechnologiesLtd62

Using interface in ProgramsImporting the folderwhere myinterface.classfile is storedimportimport java.io.*java.io.*; ;importimport mypackage.*mypackage.*; intln(“ ”” ( (xx yy gmain(Stringargs[args[])]){{denodeno dd newnew demodemo( () ) ; ;d.addd.add(10(10, ,2020) ); ;}} 2005, Infosys TechnologiesCopyrightLtd63

Interfaces Contd Comparable to a pure abstract classClasses implement, by providing definitions to the methods of theinterfaceInheritance is possible in interfaces, even multiple inheritance is possibleCopyright 2005, Infosys TechnologiesLtd64

Why use Packages ?Just think of Writing thecode from the scratch,each time you create anapplicationYou’ll end up spending yourprecious time and energy andfinally land up with a Hugecode accumulated beforeyou.Copyright 2005, Infosys TechnologiesLtd65

Reusing The Existing CodeReusability of code is one ofthe most importantrequirements in the softwareindustry.Reusability saves time, effortand also ensures consistency.A class once developedcan be reused by anynumber of programswishing to incorporatethe class in thatparticular program.Copyright 2005, Infosys TechnologiesLtd66

Concept of PackagesIn Java, the codes which can be reused byother programs is put into a “Package”.A Package is a collection of classes, interfacesand/or other packages.Packages areinterfacesessentially apackagesmeans ofclasseorganizingsclasses togetherPackaas groups.geCopyright 2005, Infosys TechnologiesLtd67

Features of PackagesPackages are useful for the following purposes: Packages allow you toorganize your classes into smaller units ( such as folders ) and make iteasy to locate and use the appropriate class file.It helps to avoid naming conflicts. When you are working with a number ofclasses, it becomes difficult to decide on names of the classes & methods.At times you would want to use the same name, which belongs to ananother class. Package, basically hides the classes and avoids conflicts innames.Packages allow you to protect your classes, data and methods in a largerway than on a class-to-class basis.Package names can be used to identify your classes.Copyright 2005, Infosys TechnologiesLtd68

An Example on the use of PackagesPackage CircleMethod tofind area ofthe circleSomeClass MethodImportSomeMethodTo find the area of a circle on the frontface of the cube, we need not write acode explicitly to find the area of thecircleWe will import the package into ourprogram and make use of the areamethod already present in the package“circle”.Copyright 2005, Infosys TechnologiesLtd69

Importing a PackageIn Java, the Packages (where the required method is already created) canbe imported into any program where the method is to be used.We can import a Package in the following manner :import package name . class name ;Suppose you wish to use a class say My Class whose location is asfollows :My PackageMy Sub PackageThis class can be imported as follows :import My Package . MySub Package . My Class ;Copyright 2005, Infosys TechnologiesLtd70My Class

Creating a PackageIn Java Packages arecreated in the followingmanner :Package package name ntadd(intx,x,intinty)y)Methodto add( ){{return(return(xx yy));;}}}}mypackageCopyright 2005, Infosys TechnologiesLtd71

Compiling the packagejavacjavac -d-d c:\c:\JavaProgsJavaProgs ulaClate .When the above commandis executed on thecommand prompt, thecompiler creates a foldercalled “mypackage” in ourJavaProgs directory andstores the“Calculate.class” into thisfolderssCopyright 2005, Infosys TechnologiesLtd72

Standard Java PackagesThe Three Java Packages that are essential to any Java programare :javajava. .langlangjavajava. .ioiojava .langContains classes that form the basis ofthe design of the programminglanguage of Javajava .iojavajava. .utilutilThe use of streams for all input outputoperations in Java is handled by thejava.io packagejava . utilContains classes and interfaces that provide additional utility butmay not be always vital.Copyright 2005, Infosys TechnologiesLtd73

java.lang packageOne of the most important classes defined in this package is Object and itrepresents the root of the java class hierarchy.This package also holds the “wrapper” classes such as Boolean,Characters, Integer, Long, Float and Double.Many a times it is necessary to treat the non-object primitive datatypes ofint, char, etc. as objects.Thus Java defines “wrapper” classes that enable us to treat even primitivedata types as objects.These wrapper classes are found in the package“java.lang”.Other classes found in this package are :Math – which provides commonly used mathematical functions like sine,cosine and square root.String & String Buffer – Encapsulate commonly used operations oncharacter strings.Copyright 2005, Infosys TechnologiesLtd74

Some of the important methods of Math class int abs(int i) -- returns the absolute value of I long abs(long l) -- returns the absolute value of l float abs(float f) -- returns the absolute value of f double abs(double d) -- returns the absolute value of d double ceil(double d) -- returns as a double the smallest integer thatis not less than d double floor(double d) --- returns as a double the largest integerCopyright 2005, Infosys TechnologiesLtd75

java.io packageThis package has two very important abstract classes :Input Stream – This class defines the basic behavior required for input.Output stream – This class is the basis of all the classes that deal withoutput operations in Java.Since these are abstract classes, they cannot be used directly but mustbe inherited, so that the abstract methods can be implemented.All I/O stream classes are derived from either of these classes.Copyright 2005, Infosys TechnologiesLtd76

java.io packageThe classes derived in Inputstream and Outputstream can only read fromor write to the respective files.We cannot use the same class for both reading and writing operations.An exception to this rule is the class “RandomAccessFile”.This is the class used to handle files that allow random access and iscapable of mixed reading and writing operations on a file.There are two additional interface to this package : Data input Data output These classes are used to transfer data other than bytes orcharactersCopyright 2005, Infosys TechnologiesLtd77

Java.util packageOne of the most important package in this package is the class “Date”,which can be used to represent or manipulate date and time information.In addition, the class also enable us to account for time zones .Java helps us to change the size of an array which is usually fixed, bymaking use of the class “Vector”. This class also enable us to add,remove and search for items in the array.Copyright 2005, Infosys TechnologiesLtd78

Tips on using packagesThe statement :import java.awt.* ;Will include all the classes available in the “awt” subdirectorypresent in the java directory.While creating a package, care should be taken that thestatement for creating a package must be written before anyother import statementsLEGALILLEGALpackage mypackage ;import java . io;import java . io;package mypackage ;Copyright 2005, Infosys TechnologiesLtd79

Important Packages in Javajava.langjava.iojava.appletYou don’t need to explicitly import this package. It is alwaysimported for you.This package consists of classes that help you for all theInput and Output operations.This package consists of classes that you need, to executean applet in the browser or an appletviewer.java.awtThis package is useful to create GUI applications.java.utilThis package provides a variety of classes and interfacesfor creating lists, calendar, date, etc.java.netThis package provides classes and interfaces for TCP/IPnetwork programming.Copyright 2005, Infosys TechnologiesLtd80

Declaring and Access Control

ArraysAn array is a data structure which defines an ordered collection of a fixednumber of homogeneous data elementsThe size of an array is fixed and cannot increase to accommodate moreelementsIn Java, array are objects and can be of primitive data types or referencetypesAll elements in the array must be of the same data typeCopyright 2005, Infosys TechnologiesLtd82

ArraysDeclaring Arrays Variables elementType [] arrayName ;or elementType arrayName [];where elementType can be any primitive data type or reference typeExample:int IntArray[];Pizza[] mediumPizza, largePizza;Copyright 2005, Infosys TechnologiesLtd83

ArraysConstructing an Array arrayName new elementType [ noOfElements ];Example:IntArray new int[10];mediumPizza new Pizza[5];largePizza new Pizza[2];Declaration and Construction combinedint IntArray new int[10];Pizza mediumPizza new Pizza[5];Copyright 2005, Infosys TechnologiesLtd84

ArraysInitializing an Array elementType [] arayName { arrayInitializerCode };Example:int IntArray[] {1, 2, 3, 4};char charArray[] {‘a’, ‘b’, ‘c’};Object obj[] {new Pizza(), new Pizza()};String pets[] {“cats”, “dogs”};Copyright 2005, Infosys TechnologiesLtd85

IO Facilities in Java

OverviewIO Streams in JavaUnderstanding some fundamental streamsCreating streams for required functionalitySome advanced streamsCopyright 2005, Infosys TechnologiesLtd87

StreamsStreams are channels of communicationProvide a good abstraction between the source and destinationCould also act as a shield to lower transport implementationMost of Java’s IO is based on streams– Byte-oriented streams– Character-oriented streamsCopyright 2005, Infosys TechnologiesLtd88

Concatenating StreamsDataInputStreamFileInputStreamCopyright 2005, Infosys TechnologiesLtd89FileObject

Input & Output Streams

StreamsA stream can be thought of as a Conduit (pipe) for data between a sourceand the destination.Two types of Streams are1. Low level streams2. High level streamsCopyright 2005, Infosys TechnologiesLtd91

Low level streams & High level streamsStreams which carries bytes are called low level streams.Examples are FileInputStream and FileOutputStream.Streams which carries primitive data types are called highlevel streams. Examples are DataInputStream andDataOutputStream.Copyright 2005, Infosys TechnologiesLtd92

InputStream & OutputStreamInputStreams are used for reading the data from the source.OutputStreams are used for writing the data to thedestination.Copyright 2005, Infosys TechnologiesLtd93

utputStreambytesCopyright 2005, Infosys TechnologiesLtd94Javaprogram

Writing Primitives to a FileDataOutputStream dos new DataOutputStream( No);Copyright 2005, Infosys TechnologiesLtd95

Filter StreamsFilter contents as they pass through the streamFilters can be concatenated as seen beforeSome filter streams– Buffered Streams– LineNumberInputStream– PushBackInputStream– PrintStreamCopyright 2005, Infosys TechnologiesLtd96

Conversion StreamsInputStreamReader: bridge from byte streams to character streamsBufferedReader in newBufferedReader( r: bridge from chararcter streams to byte streamsCopyright 2005, Infosys TechnologiesLtd97

ReviewStreams are the basis of Java’s IOPre-defined streams for many situationsStreams need to be concatenatedConversion streams available for byte to character and vice-versaconversionCopyright 2005, Infosys TechnologiesLtd98

String classA string is a collection of charactersHas equals( ) method that should be used to compare the actual stringvaluesLot of other methods are available which are for the manipulation ofcharacters of the stringCopyright 2005, Infosys TechnologiesLtd99

public class Stringcomparison{public static void main(String args[]) {String ss1 new String("Rafiq");String ss2 new String("Rafiq");String s1 "Rafiq";String s2 "Rafiq";System.out.println(" comparison for StringObjects: " (ss1 ss2));System.out.println(" comparison for StringLiterals: " (s1 s2));System.out.println(" equals( ) comparison for StringObjects:" (ss1.equals(ss2)));System.out.println(" equals( ) comparison for StringLiterals:" (s1.equals(s2)));}}Copyright 2005, Infosys TechnologiesLtd100

class checkstring{ public static void main(String args[]){String str "HELLO guys & girls";System.out.println("The String is:" str);System.out.println("Length of the String is:" str.length());System.out.println("Character at specifiedposition:" str.charAt(4));System.out.println("substring of the Stringis:" str.substring(6,10));System.out.println("Index of the specifiedcharacter:" str.indexOf("g"));System.out.println("conversion touppercase:" str.toUpperCase());System.out.println("conversion touppercase:" str.toLowerCase());}}Copyright 2005, Infosys TechnologiesLtd101

String Buffer The prime difference between String & StringBuffer class is that thestringBuffer represents a string that can be dynamically modified. StringBuffer’s capacity could be dynamically increased eventhough it’scapacity is specified in the run time.ConstructorsStringBuffer()StringBuffer(int capacity)StringBuffer(String str)Methodsint length()int capacity()void setLength(int len)Copyright 2005, Infosys TechnologiesLtd102

String Bufferch

The Java Platform The Java platform has two components: The Java Virtual Machine (Java VM) The Java Application Programming Interface(Java API) The Java API is a large collection of ready-made software components that provide many useful capa

Related Documents:

java.io Input and output java.lang Language support java.math Arbitrary-precision numbers java.net Networking java.nio "New" (memory-mapped) I/O java.rmi Remote method invocations java.security Security support java.sql Database support java.text Internationalized formatting of text and numbers java.time Dates, time, duration, time zones, etc.

Java Version Java FAQs 2. Java Version 2.1 Used Java Version This is how you find your Java version: Start the Control Panel Java General About. 2.2 Checking Java Version Check Java version on https://www.java.com/de/download/installed.jsp. 2.3 Switching on Java Console Start Control Panel Java Advanced. The following window appears:

JAR Javadoc Java Language jar Security Others Toolkits: FX Java 2D Sound . Java Programming -Week 1. 6/25. Outline Java is. Let’s get started! The JDK The Java Sandbox . into your namespace. java.lang contains the most basic classes in the Java language. It is imported automatically, so

–‘java’ command launches Java runtime with Java bytecode An interpreter executes a program by processing each Java bytecode A just-in-time compiler generates native instructions for a target machine from Java bytecode of a hotspot method 9 Easy and High Performance GPU Programming for Java Programmers Java program (.

3. _ is a software that interprets Java bytecode. a. Java virtual machine b. Java compiler c. Java debugger d. Java API 4. Which of the following is true? a. Java uses only interpreter b. Java uses only compiler. c. Java uses both interpreter and compiler. d. None of the above. 5. A Java file with

besteht aus der Java-API (Java Application Programming Interface) und der Java-VM (Java Virtual Machine). Abbildung 1: Java-Plattform Die Java-API ist eine große Sammlung von Java-Programmen, die in sog. Pakete (packages) aufgeteilt sind. Pakete sind vergleichbar mit Bibliotheken in anderen Programmiersprachen und umfassen u.a.

CORE JAVA TRAINING COURSE CONTENT SECTION 1 : INTRODUCTION Introduction about Programming Language Paradigms Why Java? Flavors of Java. Java Designing Goal. Role of Java Programmer in Industry Features of Java Language. Installing Java Di

Instructional Topics . 1 : 1: Building a Reading Life . Topic 1: Making Reading Lives Topic 2: Making Texts Matter Topic 3: Responding to Our Reading Through Writing . 2: Nonficti