background preloader

Java

Facebook Twitter

Java Magazine. Java Concurrency / Multithreading. Asynchronous task handling is important for any application which performs time consuming activities, as IO operations. Two basic approaches to asynchronous task handling are available to a Java application: application logic blocks until a task completesapplication logic is called once the task completes, this is called a nonblocking approach. CompletableFuture extends the functionality of the Future interface for asynchronous calls. It also implements the CompletionStage interface. It adds standard techniques for executing application code when a task completes, including various ways to combine tasks. This callback can be executed in another thread as the thread in which the CompletableFuture is executed.

The following example demonstrates how to create a basic CompletableFuture. CompletableFuture.supplyAsync(this::doSomething); CompletableFuture.supplyAsync runs the task asynchronously on the default thread pool of Java. Sun Java Certification Exams. Java oca. Java & OO Fundamentals. The Java™ Tutorials. The Java Tutorials are practical guides for programmers who want to use the Java programming language to create applications. They include hundreds of complete, working examples, and dozens of lessons. Groups of related lessons are organized into "trails".

The Java Tutorials primarily describe features in Java SE 8. For best results, download JDK 8. What's New The Java Tutorials are continuously updated to keep up with changes to the Java Platform and to incorporate feedback from our readers. This release of the tutorial corresponds to the JDK 8u101 release. Two new processing limit properties, entityReplacementLimit and maxXMLNameLimit, have been added to JAXP. Trails Covering the Basics These trails are available in book form as The Java Tutorial, Sixth Edition. Creating Graphical User Interfaces Creating a GUI with Swing — A comprehensive introduction to GUI creation on the Java platform.Creating a JavaFX GUI — A collection of JavaFX tutorials. Specialized Trails and Lessons. The Java™ Tutorials. The Java Tutorials have been written for JDK 8.

Examples and practices described in this page don't take advantage of improvements introduced in later releases and might use technology no longer available. See Java Language Changes for a summary of updated language features in Java SE 9 and subsequent releases. See JDK Release Notes for information about new features, enhancements, and removed or deprecated options for all JDK releases. The Java Tutorials are practical guides for programmers who want to use the Java programming language to create applications. They include hundreds of complete, working examples, and dozens of lessons. Groups of related lessons are organized into "trails".

Trails Covering the Basics These trails are available in book form as The Java Tutorial, Sixth Edition. Creating Graphical User Interfaces Creating a GUI with Swing — A comprehensive introduction to GUI creation on the Java platform. Specialized Trails and Lessons Trails Covering the Basics. Java SE Technical Documentation. Programmer Level I Exam (The Java™ Tutorials > Bonus > Preparation for Java Programmer Language Certification)

This page maps sections in the Java Tutorials to topics covered in the Java SE 7 Programmer I exam. This exam is associated with the "Oracle Certified Associate, Java SE 7 Programmer" certificate. The topics covered in this exam are: Section 1: Java Basics Item 1: Define the scope of variables. Variables Item 2: Define the structure of a Java class. Item 3: Create executable Java applications with a main method. Item 4: Import other Java packages to make them accessible in your code. Section 2: Working with Java Data Types Item 1: Declare and initialize variables. Item 2: Differentiate between object reference variables and primitive variables. Item 3: Read or write to object fields. Item 4: Explain an object's lifecycle. Item 5: Call methods on objects. Using Objects Item 6: Manipulate data using the StringBuilder class and its methods.

Item 7: Create and manipulate strings. Section 3: Using Operators and Decision Constructs Item 1: Use Java operators. Expressions, Statements, and Blocks Arrays. Java Programming/Creating Objects. Before a Java object can be created the class byte code must be loaded from the file system (with .class extension) to memory. This process of locating the byte code for a given class name and converting that code into a Java class instance is known as class loading. There is one class created for each type of Java class. All objects in Java programs are created on heap memory. An object is created based on its class.

You can consider a class as a blueprint, template, or a description how to create an object. When an object is created, memory is allocated to hold the object properties. An object reference pointing to that memory location is also created. The Java Virtual Machine (JVM) keeps track of the usage of object references. The obj variable contains the object reference pointing to an object created from the MyObject class. Creating object with the new keyword[edit] 99% of new objects are created using the new keyword. Creating object by cloning an object[edit] Object Serialization. Lesson: Generics (The Java™ Tutorials > Learning the Java Language) In any nontrivial software project, bugs are simply a fact of life. Careful planning, programming, and testing can help reduce their pervasiveness, but somehow, somewhere, they'll always find a way to creep into your code.

This becomes especially apparent as new features are introduced and your code base grows in size and complexity. Fortunately, some bugs are easier to detect than others. Compile-time bugs, for example, can be detected early on; you can use the compiler's error messages to figure out what the problem is and fix it, right then and there. Runtime bugs, however, can be much more problematic; they don't always surface immediately, and when they do, it may be at a point in the program that is far removed from the actual cause of the problem. Generics add stability to your code by making more of your bugs detectable at compile time. Lesson: Generics (The Java™ Tutorials > Bonus) Introduced in J2SE 5.0, this long-awaited enhancement to the type system allows a type or method to operate on objects of various types while providing compile-time type safety.

It adds compile-time type safety to the Collections Framework and eliminates the drudgery of casting. IntroductionDefining Simple GenericsGenerics and SubtypingWildcardsGeneric MethodsInteroperating with Legacy CodeThe Fine PrintClass Literals as Runtime-Type TokensMore Fun with WildcardsConverting Legacy Code to Use GenericsAcknowledgements.