Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Wrapper Classes  Sometimes we want to use a primitive type as an object, so there are wrapper classes that will help us.  In particular, we need to.

Similar presentations


Presentation on theme: "1 Wrapper Classes  Sometimes we want to use a primitive type as an object, so there are wrapper classes that will help us.  In particular, we need to."— Presentation transcript:

1 1 Wrapper Classes  Sometimes we want to use a primitive type as an object, so there are wrapper classes that will help us.  In particular, we need to be familiar with the Double and Integer classes.  For example Integer ageObj = new Integer (20); uses the Integer class to create an object which effectively represents the integer 20 as an object  Autoboxing automatically converts between wrapper classes and primitive types, so that the following is also valid: Integer ageObj = 20;

2 2 Wrapper methods you need to know: From the AP Appendix:

3 3 Class Libraries  A class library is a collection of classes that we can use when developing programs  The Java standard class library is part of any Java development environment  The System class and the String class are part of the Java standard class library  Other class libraries can be obtained through third party vendors, or you can create them yourself

4 4 Packages  The classes of the Java standard class library are organized into packages  Some of the packages in the standard class library are: Package java.lang java.applet java.awt javax.swing java.net java.util javax.xml.parsers Purpose General support Creating applets for the web Graphics and graphical user interfaces Additional graphics capabilities and components Network communication Utilities XML document processing

5 5 The import Declaration  All classes of the java.lang package are imported automatically into all programs  That's why we didn't have to import the System or String classes explicitly in earlier programs  For other classes, we need to import them (like Scanner)

6 6 The import Declaration  You can import the class, and then use just the class name import import java.util.Scanner;  To import all classes in a particular package, you can use the * wildcard character import java.util.*;


Download ppt "1 Wrapper Classes  Sometimes we want to use a primitive type as an object, so there are wrapper classes that will help us.  In particular, we need to."

Similar presentations


Ads by Google