These are nice reference guides that can be printed off and viewed as a supplement to learning somewhere else.
File Input Output Cheat Sheet Importing Libraries The primary library that deals with files: Java Code: import java.io.File; The library that deals with writing to files: Java Code: import java.io.PrintWriter; FYI If there is more then one type of information that is being transferred to or from a file, it is usually best to use a record; IMO. Writing to a File Declare ...
import java.io.File;
import java.io.PrintWriter;
AWT Components Cheat Sheet Importing Libraries There are two main libraries that involve the AWT tools. This package contains the core AWT graphics classes. Contains component classes for buttons, text fields, labels, frames, panels, dialogs, and scroll panes. It also contains the layout managers such as flow layout, border layout, and grid layout. Also included are the cusrom graphics classes such as graphics, color and font. Java Code: import java.awt.*; ...
import java.awt.*;
Updated 10-30-2012 at 07:02 AM by penguinCoder
Importing the Library Before you can use an ArrayList, you must first import the necessary library. Java Code: import java.util.ArrayList Creating a Generic ArrayList Generic ArrayList is an ArrayList with a type; no other type is allowed to be inserted into the ArrayList. Java Code: ArrayList<type> listName = new ArrayList<type>(); Example of this would be: Java Code: ArrayList<String> myArrayList = new ArrayList<String>(); ...
import java.util.ArrayList
ArrayList<type> listName = new ArrayList<type>();
ArrayList<String> myArrayList = new ArrayList<String>();
Updated 10-29-2012 at 08:29 PM by penguinCoder
Brief Description: 'Virtual' Memory is the mental model, or abstraction, that the programming language provides to the programmer to explain how computer memory is managed while you program is running. It is NOT the same as physical memory. Run Time: At run time, the operating system handles the translation from 'virtual' memory addresses to physical memory addresses, and the programmer does no need to be aware of this process. Static Region: This ...
Updated 10-30-2012 at 05:19 AM by penguinCoder
Brief Description: A record is pretty much just a programmer defined data type. It combines one or more pieces of information, or potentially different data types, into one unit. Structure wise, it is just a template that defines how to interpret the contents of a sequence of memory locations. First outside of any class, define the new data type: Java Code: class recordName{ public [dataType] fieldName; ..repeat for any number of types.. } ...
class recordName{ public [dataType] fieldName; ..repeat for any number of types.. }
Just for FYI, computers cannot generate actual random numbers. They are machines, and they do what they are told; and therefore cannot just choose a number at random. Mathematicians would call the process this process 'psuedo-random' number generation, but I didn't feel that made a good title so, whatever.. Just covering all the bases. First you will have to import the library: Java Code: import java.util.Random; Next, you create a random number generator; ...
import java.util.Random;
The Scanner class can be used for many things other then just getting input from the user; however this cheat sheet/tutorial is just going to be about getting input from the user. Defining the Scanner Class Java Code: import java.util.Scanner; public class ClassName{ ...code... } It will tell the translator to look in that directory for the code defining the Scanner class. Declaring the Scanner If you ...
import java.util.Scanner; public class ClassName{ ...code... }
Updated 10-18-2012 at 01:29 AM by penguinCoder
A string is a piece of text, that is zero or more characters in length. In Java, strings are considered to be pre-built objects. The variable for a string does not store the value of the string, rather it is a reference point, or pointer, to the storage location of where the string is kept. Declaring a String: Java Code: String s1; Assigning a Value On Declaration: Java Code: String s1 = "Hello World!"; Assigning ...
String s1;
String s1 = "Hello World!";
Class Body - the area between the braces, that contains all the code. Constructors - used for initializing new objects Declarations - fields that provide the state of the class and its objects Methods - implement the behaviour of the class and its objects Fields - member variables in a class Local Variables - variables in a method or a block of code Parameters - is the list of variables in a method declaration ...
Updated 10-18-2012 at 01:30 AM by penguinCoder
Declaring a Class Java Code: class ClassName{ ...code... } Declaring a Class with Parent Java Code: class ClassName extends parentClassName{ ...code... } Declaring a class with Interface Java Code: class ClassName implements interface1, interface2, interface3{ ...code... } Declaring a Class with Fields Java Code: class ClassName{ public ...
class ClassName{ ...code... }
class ClassName extends parentClassName{ ...code... }
class ClassName implements interface1, interface2, interface3{ ...code... }
class ClassName{ public
Well I just got out of class, and I thought I would do a brain dump of some of the terminology that is utilized in Programming and Computer Science. This is going to be in more human readable format then most places I have found on the Internet. Abstract Algorithm AnalysisWhat is O(N)? Big O of N, and it is commonly pronounced, is when the run-time of an algorithm is approximately proportional to the size of the data (N), when there are large amounts of data; in the ...