Monday, 12 March 2018

Java Naming Convention

Java naming convention is a simple rule to follow as a developer to decide what to name your identifiers such as class, package, variable, constant, method etc.

Here are rules to follow in Java regarding Naming Convention

Class name: It should start with an uppercase letter and be a noun e.g. Name, String, System, Thread etc.
Interface name: It should start with an uppercase letter and be an adjective e.g. Runnable, Remote, ActionListener etc.
Method name : It should start with lowercase letter and be a verb e.g. actionExecute(), run(), print(), println() etc.
Variable name: It should start with lowercase letter e.g. lastName, messageNumber etc.
Package name: It should be in lowercase letter e.g. impl, lang, sql, util etc.
Constants name: It should be in the uppercase letter. e.g. GREEN, YELLOW, MIN_PRIORITY etc.


Interface  Furnitures
Class Chair implements Furnitures
void changeName(Strung newValue);
void employeeNo(int value);

Java strictly follows the camelcase syntax for naming the class, interface, method and variable.
Camelcase syntax: If name is combined with two words, second word will start with uppercase letter always e.g. actionExecute(), lastName, ActionEvent, ActionListener etc.

Wednesday, 7 February 2018

Simple Java program to print current date and time.

Java program to display current date.

Date function in Java Programming code.

Java Date example.
This Java Date example program describes how Java Date function from utility is being used in Java language.

import java.util.*;

public class JavaDateProgram{

          public static void main(String args[]){
              Create date object with current date and time.
 Date dateandtime = new Date();
  System.out.println("Current Time is " + dateandtime);



Current Time is Sat Feb 08 16:10:21 IST 2018

Tuesday, 29 November 2016

Facts about Variable Length Argument in Java

Variable Length Argument Rules in Java

                 Java included a feature that simplifies the creation of methods that require variable number of arguments. This is known as vararg. vararg is the short for of Variable Length Arguments.

5 Facts about Variable Length Argument Rules in Java

1. A variable-length argument is specified by three periods (…).


            static void TestVariableArgument(int ... v) {

         This syntax tells the compiler that TestVariableArgument( ) can be called with zero or more arguments.

2. In the case of no arguments, the length of the array is zero.

3. A method can have “normal” parameters along with a variable-length parameter and the variable-length parameter must be the last parameter declared by the method.

4. Overloading a method that takes a variable-length argument is possible.

5. If a method call conflicts with two methods that implements variable argument or other leads to error. 

Thursday, 24 November 2016

JQuery - Introduction

jQuery is a small, light-weight and fast JavaScript library. It is cross-platform and supports different types of browsers. It is very useful for data manipulation.
  • jQuery is a small, fast and lightweight JavaScript library.
  • jQuery is platform-independent.
  • jQuery means "write less do more".
  • jQuery simplifies AJAX call and DOM manipulation.
jQuery features:
  • HTML manipulation
  • DOM manipulation
  • DOM element selection
  • CSS manipulation
  • Effects and Animations
  • Utilities
  • AJAX
  • HTML event methods
  • JSON Parsing
  • Extensibility through plug-in
To starts with,
  • A $ sign to define/access jQuery
  • A (selector) to "query (or find)" HTML elements
  • A jQuery action() to be performed on the element(s)

jQuery Syntax:

The jQuery syntax is tailor-made for selecting HTML elements and performing some action on the element(s).

Basic syntax is: $(selector).action()

$(this).hide() - hides the current element.
$("p").hide() - hides all elements.
$(".test").hide() - hides all elements with class="test".
$("#test").hide() - hides the element with id="test".