background preloader

Java

Facebook Twitter

Java For Complete Beginners - formatted strings. Strings of text can be formatted and output with the printf command.

Java For Complete Beginners - formatted strings

The printf command understands a series of characters known as a format specification. It then takes a string of text and formats it, based on the format specification passed over. As an example, supposed we wanted the Output window to display text in neat columns, like this: The first column is left-justified, and the second column is right-justified.

The code for the Exam_Name and Exam_Grade headings was this: String heading1 = "Exam_Name"; String heading2 = "Exam_Grade"; System.out.printf( "%-15s %15s %n", heading1, heading2); To get the left-justified column, you need a percentage symbol, a minus symbol, the number of characters, and then the letter "s" (lowercase). To get a right-justified column the same sequence of characters are used, except for the minus sign. To get a newline %n is used. After a comma, you type the text that you want formatting. Here's some tables of the various options. String Formatting. IdeaCanoo1440x900. IntelliJ IDEA Cheat Sheet from DZone Refcardz. By Hamlet D'Arcy Software developers know the importance of using the best tool for the job.

IntelliJ IDEA Cheat Sheet from DZone Refcardz

Often this means choosing a world-class integrated development environment (IDE), which JetBrains’ IntelliJ IDEA certainly is. But the best developers don’t just have the right tools, they are experts in those tools. This is a guide to becoming that expert. The basics of navigating and understanding the IDE are covered; but this guide is really about unlocking all the powerful features of the tool and helping you be more productive. Getting Yourself Oriented The three most important elements of the IDE are the Editor pane (a), where your code is shown, the Project pane (b), where your project’s contents are shown, and the Structure pane (c), where the details of the open object are shown. Editor Pane: Shows the currently active file, with recently viewed files in the tab bar.

Spring

Java Design Patterns With Examples. List of Java keywords. A snippet of Java code with keywords highlighted in blue and bold font List[edit] The following is a list of Java keywords, along with brief descriptions of their functions:[2] abstract boolean break.

List of Java keywords

Trail: Learning the Java Language (The Java™ Tutorials) JAVA vs C++ Contents In Java, every variable, constant, and function (including main) must be inside some class.

JAVA vs C++

Here's a simple example program: class Test { public static void main( String [] args ) { System.out.println("Hello world! "); } } Things to note: There is no final semi-colon at the end of the class definition. Learning a New Programming Language: Java for C++ Programmers. Java for C++ Programmers. (prepared by Prof.

Java for C++ Programmers

Marvin Solomon U. Wisconsin- and slightly modified by me) Contents Introduction Applications vs Applets The first thing you have to decide when writing a Java program is whether you are writing an application or an applet. An application is a stand-alone program. Java was orginally designed to build active, multimedia, interactive environments, so its standard runtime library has lots of features to aid in creating user interfaces. JavaScript You may have heard of JavaScript. The Java API The Java langauge is actually rather small and simple - an order of magnitude smaller and simpler than C++, and in some ways, even smaller and simpler than C.

Java.lang contains things like character-strings, that are essentially "built in" to the langauge. A First Example Large parts of Java are identical to C++. /** Sort the array a[] in ascending order ** using an insertion sort. void sort(int a[], int size) { for (int i = 1; i < size; i++) { // a[0..i-1] is sorted int x = a[i]; int j;