Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Dec 2016
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Ongoing study notes/ daily coding studies

    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).

    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(System.in);
    -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(System.in);
    String name;
    name = input_text.next();
    -print and println are methods of System.out
    -print stays on the same line, println moves cursor to new line(\n)
    -java.io 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
    {
    ...
    }



    (tutorialspoint.com)
    Inheritance can be defined as the process where one class aquires the properties (methods & fields) of another. With the use of inheritance the information is made manageable in hierarchical order.

    The subclass inherits the properties from a superclass

    Other names for subclass are derived class and child class
    Other names for superclass are base class and parent class

    To inherit the properties of a class use keyword extends
    class Super
    {
    ...
    }
    class Sub extends Super
    {
    ...
    }

    Subclasses inherit all the members from its superclass
    Members are fields, methods, and nested classes

    Constructors are not members and hence not inherited by subclasses,
    though constructors of super classes can be invoked from subclasses

    super and this keywords are similar, the super keyword is used in the following scenarios:
    -to differentiate the members of superclass from the members of subclass, if they have the same names
    -to invoke the superclass constructor from subclass

  2. #2
    New to the CF scene
    Join Date
    Dec 2016
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    (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

  3. #3
    New to the CF scene
    Join Date
    Dec 2016
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    (tutorialspoint.com)

    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:
    -super.variable;
    -super.method();

    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

  4. #4
    New to the CF scene
    Join Date
    Dec 2016
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    (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

  5. #5
    New to the CF scene
    Join Date
    Dec 2016
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  6. #6
    New to the CF scene
    Join Date
    Dec 2016
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    (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


 

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •