Skip to main content

Posts

Showing posts from November, 2022

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