Home » SDZ Podcast Episode 5 – Core Packages, Java Standard Libraries

Share This Post


SDZ Podcast Episode 5 – Core Packages, Java Standard Libraries

SDZ Podcast Episode 5 – Core Packages, Java Standard Libraries

Java Standard Libraries Part One

Core packages are the java.package packages.

RSS feed is http://arksoft.libsyn.com/rss

Also see OOP and Java and Behavior, Code Blocks, Modules, Program Logic

What I talk about

  • Other types of classes, Error
  • assert keyword and AssertionError can turn off with compiler option
  • debugging using System.out.println();
  • serializable keyword
  • Also, need to explain that you do not have to extend an abstract class to use its static members.
  • Also, it’s a compile-time error to try to have an abstract static method or member.
  • explain java arrays, no 2 dimensioned arrays, only arrays of arrays

Java Image

java, javax, and org

Core Packages

  • java
    • applet
      • applet is a java.awt.Panel
      • start, stop, init, destroy
      • methods to play sound
      • methods for loading images
      • other utility type methods
    • awt
      • Canvas, Panel, Frame, Button, Menu, Edit Box etc.
      • Layout management classes
      • Image processing classes
      • Color classes
      • Windows event handling classes for mouse and key events and window events.
      • Graphics drawing and shapes
      • Clipboard
      • Drag and Drop
      • Fonts and printing
    • beans
    • io
      • Streams and Buffered Streams
      • Readers and Writers
      • File IO
      • Object Streams serialization
      • Input and output streams
      • standard out, in, and error
      • Piped Streams
      • Ramdon Access File
      • Sequential Input and Output
      • Stream Tokenizer
      • String Reader and Writer
    • lang
      • Interfaces
        • Cloneable
        • Comparable
        • Iterable
        • Runnable
      • Classes
        • Object
        • Byte, Boolean, Character, Double, Float, Integer, Long, Short, String
        • Class, Package  java reflections  introspection  java.lang.reflect package
        • ClassLoader
        • Math
        • Number
        • String Buffer
        • System
        • Tread and Thread related
        • Throwable
          • All Errors and Exceptions
      • Exceptions
        • ClassCast, ArrayIndexOutOfBounds, NullPointerException
        • Exception, RuntimeException, checked and unchecked exceptions
        • NumberFormatException
        • SecurityException
      • Error
        • Error could or should try to catch java.lang. Error to provide more debug info. But typically these are not thrown or caught by a developer.
        • Errors are more related to the system and are fatal in nature.
        • Errors cause the program to crash. Errors are unchecked by the compiler.
        • NoClassDefFoundError, OutOfMemoryError
    • math
      • BigDecimal
      • BigInteger
    • net
      • sockets, cookies, URL streams,
      • Inet4, Inet6 and Inet address
      • InetSocketAddress can be hostename+port or ip+port
      • unicast, multicast, TCP an UDP
      • ServerSocket and Socket(client socket)
      • Well known ports 0 to 1023 and IANA maintains the official list of well-known and registered ranges, registered ports 1024 through 49151, dynamic or private ports 49152 through 65535
      • javax.websockets note
      • SocketIpml is an example of an abstract class in the API, which All socket classes must extend.
      • Password Authentication, network permissions, JarURLConnection, HTTPURLConnection
      • URLConnections
      • SocketException, SocketTimeOutException, MalformedURLExcption, ConnectException, UnknownHostExcpetion
    • nio
      • nio.file gives you some tools for working with folders and files on a system.
    • rmi
      • remote method invocation
      • allows you to setup and create an RMI client-server. the client may call or invoke methods on the server and get return values back.
    • security
      • deals with certificates, public and private key encryption,
      • policy files,  and permissions
    • sql
      • and javax.sql is the powerful set of classes for accessing databases
      • its called java database connectivity and is database independent, any database with a driver can be accessed with java. standard SQL can be used to manipulate the database.
      • you basically connect to a database and if that goes well you can use the direct execution of SQL or prepared statements. You will get back a resultset which is like a table of data.
      • you will see a lot of interfaces that have no implementation. This is because DriverManager gives you an implementation of Connection which gives you an implementation of ResultSet etc.
      • And this is a perfect example of the power of Interfaces.
      • So basically using Java you program the “front end to a database”.
      • By the way, let me mention right now HSQLDB a database written in Java and new rewrite of it called H2. I’ve used both and they work well.
      • SQLException and other SQLException subclasses
    • text
      • classes for handling numbers and dates time in text and conversion to actual number or date objects.
      • Also for other text formatting problems.
    • time
      • classes for handling clock and Callender type problems.
    • util
      • Arrays, ArrayList, ArrayDequeue
      • Collections such as Collection, Set, Map, List, HashMap, HashSet, EnumMap, EnumSet, Hashtable, LinkedHashMap, LinkedHashSet, LinkedList, Stack, TreeMap, TreeSet, PriorityQueue, Queue, Dictionary(Hashtable), Vector
      • Calendar, Date, Time, Gregorian Calendar, Locale, Simple Time Zone, TimeZone
      • Observable Class, Observer Interface
      • Properties files class
      • DoubleStatisticsSummary, LongStatisticsSummary and IntStatisticsSummary  give count, min, max, sum, and average.
      • Formatter interprets printf style strings
      • Random Class gives a stream of Int, Long or Double Random numbers
      • Scanner, scans Files, Streams or Sources and Strings, will split based on delimiters or whitespace.
        • Also finds tokens, search strings, and the next data of various types such as int, double, and others.  Its a  handy way to process text data.
      • Currency class
      • StringJoiner and StringTokenizer  for joining and splitting strings
      • Timer
      • UUID universal unique immutable identifier.
      • Objects have methods for operating on Objects.
        • deepEquals() similar in concept to deepClone()

Java Lang Object

  • clone
  • equals
  • finalize
  • getClass
  • toString
  • hashCode
  • notify, notify all and wait

Java Lang String

  • You can build strings from byte arrays, char arrays, Strings, StringBuffers.
  • Searching and matching
  • splitting, substring, joining strings, replace operations
  • converting primitives to strings
  • comparing strings
  • ends and starts with
  • is empty or length = 0 and length
  • to upper and lower case
  • makes char arrays from whole or part of a string
  • makes byte arrays from whole or part of a string
  • formatter for working with printf style strings

Java Util Arrays

  • make an array a List
  • binary searching of arrays
  • copying arrays and parts of arrays
  • deep equals, deep hashcode, and deep toString
  • comparing equality
  • filling an array
  • hashcodes for types of arrays
  • parallel operations on arrays using functions
  • setting all elements using functions
  • sorting arrays
  • iterating methods called spliterators
  • turns the array into a stream for use in IO operations
  • and toString for types of arrays

Java Awt Graphics class

A graphics object is an object that wraps up a piece of screen real estate. Your application based on the size of your frame is given some space on the screen. The graphics image underlying of course can be larger than that space and positioned at the top left corner of that space as 0,0  with + Y going downward and +X going across to right. Upside down Cartesian coordinates or algebra coordinates.  You usually work with BuffedImages and cast to Image and use that with Graphics or Graphics2D classes. Graphics and Graphics2D are interfaces so you would get one from the paint or paintComponent methods in Canvas, Panel or JPanel classes

  • clearing and filling rectangles
  • drawing boxes, rectangles, ovals, circles, arcs
  • drawing Strings, char arrays, and byte arrays as text
  • drawing lines and polygons
  • filling shapes
  • drawing images and textures
  • drawing in clipped regions
  • drawing in xor mode (reverse image)
  • Graphics 2D has more than this… I will cover in next podcast
  • get and set pen color for drawing or text.
  • has methods for working with fonts
  • If you want to get a sub-image from the main image you have to use BufferedImage class By making a BufferedImage with an Image object

Share This Post

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>