Ongoing coding studies/notes

  • Filter
  • Time
  • Show
Clear All
new posts

    Ongoing coding studies/notes

    I'm a rather beginner-ish coder (with some C/JS/Ruby experience), so in my efforts to acquire a coding job (and help as many people as best I can, see my website GohstIndustries for a complete zip file of my life's works, totally free), I'm intending to post here consistently daily some of the coding things I've learned for the day. They are copied verbatim from my personal notebooks, which are (sometimes) paraphrased versions of sources I'm getting the information from, in any case I'm listing reference/credits to each information source in each post as they are written at the top of each notes page in my notebooks. Hopefully this thread will be of use to readers as well as in my coding job search (if any of you know someone who needs some coding work done please keep me in mind as my skills progress, thanks).

    Here's post number 1 1/2:
    (info source unknown, due to notes being written pre-blogging-intents)
    -Scanner class is really useful for handling user input
    -the java.util library contains the Scanner class
    -use keyword import to reference classes (i.e. import java.util.Scanner)
    -import statements need to go just above Class statements
    -A class needs objects to be able to do anything
    -To create a new Scanner object: Scanner usr_input =new Scanner(;
    -keyword new is used to create new objects from a class
    -next is a Scanner method that gets the next text string from user input, i.e.:
    Scanner input_text = new Scanner(;
    String name;
    name =;
    -print and println are methods of System.out
    -print stays on the same line, println moves cursor to new line(\n) package contains many input/output (I/O) classes
    -there are two kinds of streams (data sequences):
    InPutStream: used to read data from a source
    OutPutStream: used to write data to a destination
    -a directory is a file which can contain a list of other files & directories

    -objects represent real-world objects
    -objects have states & behaviors, with states being stored as fields & methods for behaviors
    -Classes can contain 3 types of variables:
    -Local Variables: Defined inside methods, constructors, or blocks; declared & initialized within method, removed after
    -Instance Variables: within a class but outside methods; initialized with class initialization; can be accessed from within respective class
    -Class variables: declared within class, outside methods, with static keyword
    -static indicates class variable
    -every class has a constructor
    -constructors must have the same name as the class
    -classes can have more than one constructor
    singleton classes are for only creating a single instance of a class
    -3 steps for creating objects from classes:
    1. Declaration: variable declaration with a variable name & object type
    2. Instantiation: creates objects with "new" keyword
    3. Initialization: "new" keyword followed by constructor call to initialize the new object

    Rules for declaring source files:
    -each source file can only have one public class
    -multiple non-public classes are allowed for each source file
    -the file name (appended with ".java") should match the public class name
    -package statements should be the first statement of a source file if the class is defined inside a package
    -import statements (when present) must be written between the package statement and class declaration
    -java packages are a way of categorizing classes & interfaces
    -import statements are a way of giving the proper location for the compiler to find a particular class
    -extends is the keyword used to inherit the properties of a class
    -the extends syntax is as follows:
    class Super
    class Sub extends Super

    (Programming: Computer Programming for Beginners: Learn the basics of Java, SQL & C++ by Joseph Connor)
    There are a number of static methods in the java.util.array class that lets us search, sort, fill, and compare array elements:
    -public static int binarySearch(Object[ ] a, Object key) : Uses the binary search algorithm to search the specified object array for the specified value
    -public static boolean equals(long[ ] a, long [ ] a2) : If the two arrays of longs are the same then this returns true, for the arrays to be considered equal they must contain the same number of elements and all the corresponding element pairs in the array must be equal
    -public static void fill(int[ ], int val) : Assigns the specified int value to each separate element of the array of ints specified
    -public static void sort(Object[ ] a) : Allows us to sort the objects of a specified array into ascending order

    Some of the methods supported by the String class include:
    -char charAt(int index) : Returns the character at a specified index
    -int compareTo(String anotherString) : Compares two strings lexicographically
    -int compareToIgnoreCase(String str) : Also compares two strings lexicographically, but ignores case differences
    -boolean endsWith(String suffix) : Tests the string to see if it ends with the specified suffix
    -byte getBytes() : Encodes the string to a byte sequence and uses the charset that is named. The result is stored in a new byte array
    -int hashCode() : Returns a hashcode for the particular string
    -boolean matches(String regex) : Tells us if the string matches the given regular expression



      If a class is inheriting the properties of another class, and if the members of the super class have the same name as the subclass, to differentiate these variables we use keyword super as shown below:

      The Date class supports two constructors:
      -Date() : Initializes the object with the current date and time
      -Date(long milisec) : Accepts an argument that equals the number of milliseconds that have elapsed since midnight January 1,1970

      There are 3 ways to compare 2 dates:
      -getTime() to obtain the number of milliseconds that have elapsed since midnight, January 1, 1970, for both objects and then compare these two values
      -methods before(), after(), and equals(), because the 18th of the month comes before the 21st, for example, new Date(97, 3, 18 ).before(new Date(97, 3, 21)) returns true
      -compareTo() method which is defined by the Comparable interface and implemented by Date


        (JavaFX for Dummies, by Douge Lowe)

        An anonymous class, more technically called an anonymous inner class, is a class that's defined on the spot, exactly where you need it

        An anonymous class is called such because it's called on the spot and hence doesn't need a name

        Event handlers often utilize anonymous classes to avoid the need to create a separate class that explicitly implements the Event Handler interface

        One advantage of using anonymous classes for event handlers is that it lets us easily create separate event handlers for each control that generates events. Then, in the handle method, for those event handlers, you can dispense with the if statements that check the event source

        Some important terms we need to know include:
        -Event: Objects that are created when the user does something noteworthy with a component, such as clicking it
        -Event source: Objects on which events first occurred
        -Event target: Nodes that the events are directed at (typically the event sources and targets are the same)
        -Event handler: Objects that listen for events and handle them when they occur

        The javafx.event package defines the EVent Handler interface, which defines a single method named handle and which must be implimented by the event-listener object

        Events are represented by instances of the class javafx.Event of one of its many subclasses

        List views display lists of objects within boxes and are powerful JavaFX controls

        By default, choice boxes have no initial value when first displayed

        Tile pane layouts are similar to flow pane layouts, both arrange nodes in neat rows and columns, either horizontally or vertically, but in tile pane layouts all the cells are the same size

        By default, a tile pane shows five nodes in each row, using as many rows as necessary to display all its nodes

        The number of nodes per row automatically adjust when we adjust the size of tile panes

        Lines, the most basic type of shape, are created with the Line class
        Lines are created by specifying the x and y coordinates of the start and end of the line, for example:
        Line line1 = new Line(0, 0, 100, 200);

        Because both the Layout and Control classes inherit Region, you can use this property with any layout pane or control

        Three methods of the Shape class that let us create complicated shapes by combining shapes in various ways are:
        -intersect: Accepts two shapes and returns a new shape that consists only of the parts of the two shapes that overlap
        -union: Combines two shapes by adding the shapes to one another
        -subtract: Creates a new shape by subtracting one shape from another


          (Java for Dummies, by Barry Burd)

          A public class is available for use by all other classes

          To create an object requires more than just declaring a variable that has a reference type, you need to call a constructor and use the keyword new

          With many IDE's, you don't need have to type your own accessor methods

          Whenever the computer creates a new object, the computer executes the statements inside a constructor

          A constructor is like a method, except that a constructor's sole purpose is creating new objects

          In Java 8, the term lambda expression represents a short piece of code that serves as both a method declaration and a method call, all created on the fly
          Last edited by thealch3m7st; 01.01.17, 06:01.


            (Sams Teach Yourself Hava in 21 Days, by Rogers Cadenhead)

            Swing can be used to create applications featuring the following GUI components:
            -Containers: Interface elements that can hold other components

            -Labels: Information-providing graphics or text

            -Frames: Windows that can include a title bar, menu bar, and buttons for Minimize, Maximize, and Close

            -Drop-down lists: Drop-down menus or scrolling windows that can be used to select groups of related items

            -Buttons: Clickable regions with text or graphics indicating their purpose

            -Image icons: Graphics that can be added to buttons, labels, and other components

            -Check boxes and radio buttons: Small circles or squares that can be selected or deselected

            -Scrolling panes: Panels that hold components too big for a user interface that are accessed in full with a scroll bar

            -Text fields and text areas: Windows that accept keyboard input and allow text to be edited


              Cool notes bro!
              Why did you stop writing? Are you still learning java? How's it going?
              You might be interested in other books on java programming for beginners. I came across this link at one time and it was very helpful.