How to use ' this ' keyword in java?
Saturday, July 22, 2023
Use of ' this ' keyword in Java
Use of Scanner Class in Java
SCANNER CLASS:
Example 1:
import java.util.Scanner;
public class ScannerEg1 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter a number");
int a = sc.nextInt();
double sq = a * a;
double rem = sq % 10;
System.out.println("square is" + sq);
System.out.println("Last Digit is" + rem);
}
}
Example 2:
import java.util.*;
public class ScannerEg2 {
public static void main(String[] args) {
int n, sq, rem;
Scanner sc = new Scanner(System.in);
System.out.println("enter a number");
n = sc.nextInt();
sq = n * n;
System.out.println(sq);
rem = sq % 10;
System.out.println(rem);
if (n == rem) {
System.out.println("equal");
} else {
System.out.println("not equal");
}
}
}
Static function in java
How to call a method in main without creating object in Java ?
public class Staticfunc {
static void f() //Static keyword is used as the f() is called in main method without object.
{
System.out.println("Sunday");
}
public static void main(String[] args) {
System.out.println("Monday");
f();
System.out.println("friday");
}
Non-static Function in JAVA
How to call a function in main by creating object in java ?
public class NonStaticFunc {
Function Overloading using JAVA ( Method 2 )
class Func
Function Overloading using JAVA ( Method 1 )
public class FunctionOverloading1 {
Factorial Program using JAVA
public class Factorial {
Constructor Overloading using JAVA
class Constructor
JAVA - COMMAND LINE - EXAMPLE 2
public class CommandLine2 {
JAVA - COMMANAD LINE - EXAMPLE 1
public class CommandLine1 {
BufferedReader String Example2
import java.io.BufferedReader;
BufferedReader String Example1
BufferedReader String Example1
BufferedReader - Long - JAVA
import java.io.BufferedReader;
BufferedReader - Interger - JAVA
import java.io.BufferedReader;
BufferedReader-Float-JAVA
import java.io.BufferedReader;
BufferedReader-Double-JAVA
import java.io.BufferedReader;
BufferedReader - Character - JAVA
Binary to Decimal - JAVA
Area Calculation Using Function Overloading in java
Complete Works of Swami Vivekananda [Volume 8,Page - 2069]
Complete Works of Swami Vivekananda [ Volume 8, Page - 2069] Jesus Christ was God — the Personal God become man. He has manifested Himsel...
-
Complete Works of Swami Vivekananda [ Volume 8, Page - 2069] Jesus Christ was God — the Personal God become man. He has manifested Himsel...
-
First be sure that gedit is already installed in your system. If it is not installed, run this command ...