Skip to main content

Posts

Command Line Arguments In Java

Command Line Arguments In Java No input statement needed in the program itself. we can pass the input as an argument while running the program. Sometimes you will want to pass information into a program when you run it. This is accomplished by passing command line arguments to main function. To access the command line arguments inside a java program is quite easy are stored as string in string array passed to main function. Example program of command line arguments in java class CommandLineExample {    public static void main(String args[]) {    System.out.println("\nMy first input is  :"+args[0]);    }    }    Addition of two numbers in java using command line arguments  Example:write a program add two integer number    class AddCommandLine { public static void main(String args[]) { int num1=Integer.parseInt(args[0]); //type cast int num2=Integer.parseInt(args[1]); //type ...

Data Type In Java programming

  Data Type In Java with example program Unlike c++ ,Java is a strongly typed language. Data type is used to declare a variable. Every variable should be declared before using that variable in  the program. A data type defines a set of values and the operation that can be performed on them. There are  two types of data types available in Java. Primitive data type (also known as value type) In primitive data type size is predefined and stored in stack memory  Non Primitive data type(also known as reference data type) Reference data type stored in heap memory this type is not predefined Primitive data type Boolean —> Boolean data type consists of two values true/false,by default it is false Size of Boolean variable is one bit byte  —> very small integer  short —> small integer  int —>  integer number long —> big integer number char —> 0 to 9,a to z(uppercase and lowercase)special symbol    float —> floating numbe...

Variables In Java-Types of variables with examples

Variables In Java-Types of variables in java with examples Variables are defined by giving the name of data types before the variable. In Java, variables must be defined prior to their use. A variable stores values of data types .A variable has a particular size and a value associated with it. In Java, variables can only store values of primitive data types and references to object. Java defines the three types of variables. Each variable can store values of primitive data types or references to objects only. Local variable(method automatic variable) —> These are the variables  declared within a method. These are directly accessed.  Static variable(class variable) —> memory allocated only once. These variables declared using static keyword. These are directly accessed.  Instance variable —> These are the variables declared inside the class . These are s imilar to local variable. Accessing is done through object Default values for member variables If static var...

Naming Convention In Java

Naming Convention In Java-camel case example Naming Conventions are rules to be followed by giving a name to the identifier.Identifiers are program elements(such as class,object,variable,method so on ).For building software you should follow this rule to make your code look good, more efficient and more readble.Java has certain rules for naming identifier. This are given below Digit, letters, underscore or currency symbols( £, €, $ ) are allowed                The first letter of any identifier cannot be a digit An identifier name must not be a reserved words or keywords Java follows camelCase rule what is camelcase rule? CamelCase is a way to separate the words in a phrase by making the first letter of each word capitalized and not using spaces (ex :- MyFirstJavaClass) Class name —> should begin with a capital letter(In a single word) If it is multiple words, the first letter of every word begins with a capital letter. Ex :- class Stu...

Keywords in java programming

Keywords in java programming Keyword is a predefined word given by the compiler which has some specific task. Keywords also known as reserved word. All the java technology keywords are lower case . Java programming has a richer set of keywords than C language or C ++ language. Some java keywords are import —>In java programming implementing classes and methods import the packages that purpose using the keyword import. class —> In order to create a class we have use the keyword class to see an example written using the class keyword ) this —> This keyword is used to represent the method belongs to particular current object Super —> It can used in inheritance concept extends —> Also used in inheritance concepts. Accessing methods one class to another class that can done by extends keyword package —> In java there will be package which consists of number of classes and interfaces in order to access that package, using the key word package return —> Return key wor...

Oops concepts in java

oops concepts in java with example programs Oops concepts in java Oops concept is very very important to make java programming easier and increase your programming skill.Four pillars of oops are Abstraction,Encapsulation,Inheritance,Polymorphism.Another technique to carefully understand in Java is classes and objects. This article covers very simple notes for Java programming beginners. What is object and class? The basics of oops is class and object Class is a blueprint which defines some properties and behaviors.  An object is an instance of a class which has those properties and behaviors attached.A class is not allocated memory when it is defined. An object is allocated memory when it is created Class and object —> object is defined as real word entities .Object consists of property and some task Class is a blueprint that object follows, Class  consists of many number of objects Four pillars of oops are Abstraction   —> Means showing only essential parts and hi...