Thursday, 10 March 2016

MySql database

Ok. Installed a MySql database on Mac with Homebrew. Now I need to read how to use it and create tables and such.
Tutorial: http://dev.mysql.com/doc/refman/5.7/en/tutorial.html
Tutorial 2: http://www.tutorialspoint.com/mysql/

Invoice Preview

Ok. Here is an idea: to preview invoice as html and then if user presses the button download (export), it will be saved as pdf. The only question is how to make it work :D
Here is a link which might be helpful: http://pdfcrowd.com/web-html-to-pdf-java/ . Also here is an example ... haven't figure out it yet: https://docs.oracle.com/javase/tutorial/uiswing/components/text.html , and here too : https://docs.oracle.com/javase/tutorial/uiswing/components/html.html .

Friday, 4 March 2016

Java tutorials

1. http://www.tutorialspoint.com/java/index.htm
2. http://learnjavaonline.org/en/Welcome
3. Event listeners - http://docs.oracle.com/javase/tutorial/uiswing/events/index.html
4. Designing a Swing GUI in NetBeans IDE - https://netbeans.org/kb/docs/java/quickstart-gui.html
! 5. The Java™ Tutorials - http://docs.oracle.com/javase/tutorial/index.html
6. LearnITGirl - https://www.learnitgirl.com/learning_materials/java

basic sources: Oracle, NetBeans

OOP


Method Overloading:

When a class has two or more methods by same name but different parameters, it is known as method overloading.
In overriding a method has same method name, type, number of parameters etc.
Lets consider the example shown before for finding minimum numbers of integer type. If, lets say we want to find minimum number of double type. Then the concept of Overloading will be introduced to create two or more methods with the same name but different parameters. (taken from link)

The Constructors:

A constructor initializes an object when it is created. It has the same name as its class and is syntactically similar to a method. However, constructors have no explicit return type.
Typically, you will use a constructor to give initial values to the instance variables defined by the class, or to perform any other startup procedures required to create a fully formed object.
All classes have constructors, whether you define one or not, because Java automatically provides a default constructor that initializes all member variables to zero. However, once you define your own constructor, the default constructor is no longer used. (taken from link)

The this keyword

this is a keyword in Java which is used as a reference to the object of the current class, with in an instance method or a constructor. Using this you can refer the members of a class such as constructors, variables and methods.
Note The keyword this is used only within instance methods or constructors. (taken from link)
In general the keyword this is used to :
  • Differentiate the instance variables from local variables if they have same names, within a constructor or a method. (taken from link)
Call one type of constructor( parametrized constructor or default ) from other in a class. It is known as explicit constructor invocation.
class Student{

   int age
   Student(){
   this(20);   // invoking the default constructor
   }
   
   Student(int age){
   this.age=age; 
   }

}
(taken from link)


public class This_Example {
 
   //Instance variable num
   int num=10;
 
   This_Example(){
      System.out.println("This is an example program on keyword this "); 
   }

   This_Example(int num){
      //Invoking the default constructor
      this();
      
      //Assigning the local variable num to the instance variable num
      this.num=num;    
   }
   
(taken from link)

Variable Arguments(var-args):

JDK 1.5 enables you to pass a variable number of arguments of the same type to a method. The parameter in the method is declared as follows:
typeName... parameterName
In the method declaration, you specify the type followed by an ellipsis (...) Only one variable-length parameter may be specified in a method, and this parameter must be the last parameter. Any regular parameters must precede it. (taken from link)

The finalize( ) Method:

It is possible to define a method that will be called just before an object's final destruction by the garbage collector. This method is called finalize( ), and it can be used to ensure that an object terminates cleanly.
protected void finalize( )
{
   // finalization code here
}
(taken from link)