You are here: Home / Topics / Search /
Showing 1012 Search Results for :

Logging and Auding Linux Commands

Filed under: Linux on 2024-04-26 12:58:17
# Display messages in kernel ring buffer.dmesg# Display logs stored in the systemd journal.journalctl# Display logs for a specific unit (service).journalctl -u servicename

Top Linux Commands for Security

Filed under: Linux on 2024-04-26 12:57:31
# Change the current user's password.passwd# Switch to the root account with root's environment. (Login shell.)sudo -i# Execute your current shell as root. (Non-login shell.)sudo -s# List sudo privileges for the current user.sudo -l# Edit the sudoers configuration file.visudo# Display the current SE

Top Linux Commands for Disk Usage

Filed under: Linux on 2024-04-26 12:56:36
# Show free and used space on mounted filesystemsdf -h# Show free and used inodes on mounted filesystemsdf -i# Display disks partitions sizes and typesfdisk -l# Display disk usage for all files and directories in human readable formatdu -ah# Display total disk usage off the current directorydu -sh&n

Top Linux Commands for File Transfers

Filed under: Linux on 2024-04-26 12:56:06
# Secure copy file.txt to the /tmp folder on serverscp file.txt server:/tmp# Copy *.html files from server to the local /tmp folder.scp server:/var/www/*.html /tmp# Copy all files and directories recursively from server to the current system's /tmp folder.scp -r server:/var/www /tmp# Synchronize /ho

Top Linux Commands for Searching Operations

Filed under: Linux on 2024-04-26 12:54:27
# Search for pattern in filegrep pattern file# Search recursively for pattern in directorygrep -r pattern directory# Find files and directories by namelocate name# Find files in /home/john that start with "prefix".find /home/john -name 'prefix*'# Find files larger than 100MB in /homefind /home -size

Top Linux Commands for Installing Packages

Filed under: Linux on 2024-04-26 12:53:52
# Search for a package by keyword.yum search keyword# Install package.yum install package# Display description and summary information about package.yum info package# Install package from local file named package.rpmrpm -i package.rpm# Remove/uninstall package.yum remove package# Install software fr

Top Linux Commands for Archieved (Tar Files)

Filed under: Linux on 2024-04-26 12:53:13
# Create tar named archive.tar containing directory.tar cf archive.tar directory# Extract the contents from archive.tar.tar xf archive.tar# Create a gzip compressed tar file name archive.tar.gz.tar czf archive.tar.gz directory# Extract a gzip compressed tar file.tar xzf archive.tar.gz# Create a tar 

Top Linux command for Networking purpose

Filed under: Linux on 2024-04-26 12:52:37
# Display all network interfaces and IP addressip a# Display eth0 address and detailsip addr show dev eth0# Query or control network driver and hardware settingsethtool eth0# Send ICMP echo request to hostping host# Display whois information for domainwhois domain# Display DNS information for domain

File permission commands in Linux

Filed under: Linux on 2024-04-26 12:51:57
PERMISSION      EXAMPLE        U   G   W       rwx rwx rwx     chmod 777 filename       rwx rwx r-x     chmod 775 filename       rwx r-x r-x     chmod 755 filename&n

Process Management Top Linux Commands

Filed under: Linux on 2024-04-26 12:51:21
# Display your currently running processesps# Display all the currently running processes on the system.ps -ef# Display process information for processnameps -ef | grep processname# Display and manage the top processestop# Interactive process viewer (top alternative)htop# Kill process with process I

File and Directory Management Top Linux commands

Filed under: Linux on 2024-04-26 12:50:52
# List all files in a long listing (detailed) formatls -al# Display the present working directorypwd# Create a directorymkdir directory# Remove (delete) filerm file# Remove the directory and its contents recursivelyrm -r directory# Force removal of file without prompting for confirmationrm -f file# 

User Information and Management Top Linux Commands

Filed under: Linux on 2024-04-26 12:49:59
# Display the user and group ids of your current user.id# Display the last users who have logged onto the system.last# Show who is logged into the system.who# Show who is logged in and what they are doing.w# Create a group named "test".groupadd test# Create an account named john, with a comment of "

Performance Monitoring and Statistics Top Linux Commands

Filed under: Linux on 2024-04-26 12:49:19
# Display and manage the top processestop# Interactive process viewer (top alternative)htop# Display processor related statisticsmpstat 1# Display virtual memory statisticsvmstat 1# Display I/O statisticsiostat 1# Display the last 100 syslog messages  (Use /var/log/syslog for Debian based syste

Hardware Information Top Linux Commands

Filed under: Linux on 2024-04-26 12:48:22
# Display messages in kernel ring bufferdmesg# Display CPU informationcat /proc/cpuinfo# Display memory informationcat /proc/meminfo# Display free and used memory ( -h for human readable, -m for MB, -g for GB.)free -h# Display PCI deviceslspci -tv# Display USB deviceslsusb -tv# Display DMI/SMBIOS (h

System Information Top Linux Commands

Filed under: Linux on 2024-04-26 12:47:52
# Display Linux system informationuname -a# Display kernel release informationuname -r# Show operating system information such as distribution name and versioncat /etc/os-release# Show how long the system has been running + loaduptime# Show system host namehostname# Display all local IP addresses of

Program to explain Generic Interfaces in Java

Filed under: Java on 2024-04-13 09:09:43
//  Program to explain Generic Interfaces.interface MinMax<T extends Comparable<T>> {T min();T max();}class MyClass<T extends Comparable<T>> implements MinMax<T> {T[ ] vals;MyClass(T[ ] o) { vals = o;}public T min() { T v = vals[0

Program to explain Generic class with Wildcard in Java

Filed under: Java on 2024-04-13 09:06:42
// Program to explain Generic class with Wildcard.class  GenericStats<T extends Number> {T[ ]  nums;   GenericStats(T[ ]  o) { nums = o;}double average() { double sum = 0.0; for(int i=0; i < nums.length; i++) {  sum += nums[ i

Program 2 to explain Generic method with Bounded type in Java

Filed under: Java on 2024-04-12 18:38:35
// Program to explain Generic method with Bounded type.// GenericType<? extends upperBoundType>import java.util.ArrayList;import java.util.List;public class  GenericTest10 {public static double getAverage(List<? extends Number> numberList) { double total = 0.0; f

Program to explain Generic Method in Java

Filed under: Java on 2024-04-12 18:37:56
// Program to explain Generic Method.public class  GenericTest7 {// generic method printArraypublic static <T> void printArray(T[ ] inputArray) { // display array elements for (T element : inputArray)  System.out.printf("%s  ", element); System.out.print

Program to explain Simple Generic class in Java

Filed under: Java on 2024-04-12 18:32:56
// Program to explain Simple Generic class.class   A<T> {T ob;A(T o) { ob = o;}T getob() { return ob;}void showType() { System.out.println("Type of T is " + ob.getClass().getName());}}public class  GenericTest1{public static void main(String args[ ]

How did I Setup bootstrap css in my Java EE project?

Filed under: Java EE on 2024-03-30 20:48:24
During my setup of java EE project. I faced one problem. I was unable to include bootstrap css in my project. I tried many ways to do this.<link rel="stylesheet" href="assets/vendor/bootstrap/css/bootstrap.min.css"/>But it was not being included in my webpages (.jsp pages) so i searched on goo

Project Structure - TypeScript

Filed under: TypeScript on 2024-03-18 12:45:47
Create two folders with the name ‘src’ and ‘public’. ‘src’ will be responsible to keep ts files & ‘public’ will be responsible to keep js & html files.Execute the following commands:tsc --initThis command will be responsible to create a tsconfig.json file. Open the tsconfig.j

Parallel Programming with Axios - TypeScript

Filed under: TypeScript on 2024-03-18 12:35:28
Example 1:As we can see from the output, all three sleep functions run and they print out how long they have run for. We can also see how long the main function has run, just over 3000ms. This shows that we are running these tasks in parallel, if we weren't, the main function would have run for abou

Consuming Rest Api - Typescript

Filed under: TypeScript on 2024-03-18 12:28:53
APIs are mechanisms that enable two software components to communicate with each other using a set of definitions and protocols. For example, the weather bureau's software system contains daily weather data.Example 1: Fetch Data & use JSON.stringifymain.tsimport axios from 'axios';async function

Generics in Typescript

Filed under: TypeScript on 2024-03-18 12:15:16
The purpose of generics in programming languages, including TypeScript, is to provide a way to write reusable code that can work with different types while maintaining type safety. Generics allow you to define types or functions that can adapt to various data types, without sacrificing compile-time 

Indexable Type Interface - Typescript

Filed under: TypeScript on 2024-03-18 12:04:22
In TypeScript, an indexable type interface allows you to define a type that can be accessed using indexing, similar to how you access elements in an array or properties in an object. This feature allows you to specify the types for indexing operations using specific key types.To define an indexable 

Excess Property Checks in Interface - Typescript

Filed under: TypeScript on 2024-03-18 11:57:41
In TypeScript, excess property checks occur when you try to assign an object literal to a variable or parameter with a defined type or interface that doesn't include all the properties of the object literal. By default, TypeScript performs excess property checks to ensure type safety and prevent pot

Optional Property interface typescript

Filed under: TypeScript on 2024-03-18 11:50:20
In TypeScript, you can define optional properties in an interface by appending a question mark (?) to the property name. This allows you to specify that a property is not required to be present in objects that implement the interface.Example 3: Optional Propertyindex.ts:interface Person {  &nbs

Interface Duck type in Typescript

Filed under: TypeScript on 2024-03-18 11:48:38
Duck Typing is a way of programming in which an object passed into a function or method supports all method signatures and attributes expected of that object at run time. The object's type itself is not important. Rather, the object should support all methods/attributes called on it.It refers to the

Interface in Typescript

Filed under: TypeScript on 2024-03-18 11:41:03
In TypeScript, an interface is a way to define the structure of an object. It specifies the properties and methods that an object should have. Interfaces are used for type checking during development and for documentation purposes.Example 1:index.ts:interface Person {name: string;age: number;greet: 

Abstract Class in Typescript

Filed under: TypeScript on 2024-03-18 11:37:35
Abstraction in TypeScript is a concept that allows you to create classes with abstract methods and properties. Abstract classes cannot be instantiated directly but serve as a blueprint for other classes to inherit from.Example 1:index.ts:abstract class Animal {name: string;constructor(name: string) 

Inheritance in TypeScript

Filed under: TypeScript on 2024-03-18 11:36:27
Inheritance is a mechanism that allows a class to inherit properties and methods from another class. It enables code reuse and promotes the concept of a hierarchical relationship between classes. TypeScript supports single inheritance, meaning a class can only inherit from a single base class. To im

TypeCasting in Typescript

Filed under: TypeScript on 2024-03-18 11:11:32
TypeScript supports typecasting, which allows you to explicitly change the type of a value. There are following ways to perform typecasting in TypeScript: using the as keyword and using angle bracket syntax (<>).In TypeScript, assertion and typecasting are often used interchangeably, but they 

TypeScript - Basic Types of Data

Filed under: TypeScript on 2024-03-18 11:01:22
JavaScript has three very commonly used primitives: string, number, and boolean. Each has a corresponding type in TypeScript. string represents string values like "Hello, world" number is for numbers like 42. JavaScript does not have a special runtime value for integers, so there’s 

Singleton Design Pattern - TypeScript

Filed under: TypeScript on 2024-03-14 17:15:36
The Singleton pattern can be useful in various scenarios where you need to ensure that there is only one instance of a class and provide global access to that instance. Some real-time use cases of the Singleton pattern include:Database Connections: When working with a database, you may want to have 

Creating Class in Typescript

Filed under: TypeScript on 2024-03-14 11:08:37
TypeScript offers full support for the class keyword introduced in ES2015.Class MembersHere’s the most basic class - an empty one:class Point {}This class isn’t very useful yet, so let’s start adding some members.FieldsA field declaration creates a public writeable property on a class:class Po

TypeScript Overview and Installation Guides

Filed under: TypeScript on 2024-03-14 10:06:45
TypeScript is an open-source language that is developed and maintained by Microsoft under the Apache 2 license. TypeScript is a strongly typed superset of JavaScript which compiles to plain JavaScript. It needs a compiler to compile and generate in a JavaScript file. TypeScript is the ES6 

Concepts of Typescript

Filed under: TypeScript on 2024-03-14 10:04:15
TypeScript is a programming language developed by Microsoft that extends JavaScript by adding static typing to it. It aims to enhance the development experience by providing better tooling, error checking, and code organization. Here are some key concepts in TypeScript: Static Typing: TypeScrip

How to get Database data using Hibernate? Explained by Impl class

Filed under: Java on 2024-03-11 21:27:10
Before viewing this example. Go and learn  (Hibernate Configuration using java file)package com.mysite.firstJavaDbApp.serviceImpl;import java.util.List;import org.hibernate.Session;import org.hibernate.SessionFactory;import org.hibernate.Transaction;import com.mysite.firstJavaDbApp.beans.Employ

Hibernate Configuration using Java Singleton Class

Filed under: Java on 2024-03-11 21:24:26
package com.mysite.firstJavaDbApp.config;import java.util.Properties;import org.hibernate.SessionFactory;import org.hibernate.boot.registry.StandardServiceRegistryBuilder;import org.hibernate.cfg.Configuration;import org.hibernate.service.ServiceRegistry;import com.mysite.firstJavaDbApp.beans.Employ

Java Program to find area of triangle

Filed under: Java on 2024-03-05 21:41:47
import java.util.Scanner;class AreaOfTriangle {  public static void main(String args[])    {              Scanner s= new Scanner(System.in);               System.out.println("Enter the width

Java Program to find area of rectangle

Filed under: Java on 2024-03-05 21:40:08
import java.util.Scanner;class AreaOfRectangle {  public static void main(String args[])    {              Scanner s= new Scanner(System.in);              System.out.println("Enter the lengt

Java Program to find area of circle

Filed under: Java on 2024-03-05 21:33:32
import java.util.Scanner;class AreaOfCircle {  public static void main(String args[])    {              Scanner s= new Scanner(System.in);               System.out.println("Enter the radius:

Classes in Java

Filed under: Java Tutorial on 2024-03-03 20:42:59
In Object-Oriented Programming language, Classes and Objects are the essential building blocks. The “class” keyword is used to declare the class followed by a reference name.Syntax:class Car {//class body}Classes are known as the blueprint of object creation. Classes that are defined by the user

Type Casting in Java

Filed under: Java Tutorial on 2024-03-03 20:36:44
In Java, Type Casting is a process of converting a variable of one data type into another.Type casting can be categorized into two types:Implicit type castingExplicit type castingImplicit typecasting:It is known as widen or automatic type casting. The process to convert a small range data type varia

Primitive Data Types in java

Filed under: Java Tutorial on 2024-03-01 21:08:59
There are eight primitive data types that are supported in Java programming language. These are the fundamental and predefined datatypes of the programming language. Java determines the size of each primitive data type, it cannot be changed. Reserved keywords represent primitive data types.The primi

Understanding Variables in Java

Filed under: Java Tutorial on 2024-03-01 20:50:25
In Java, the variables can be declared to store data in the program for a specific time. In a programming language, few variations are there todeclare a variable. The following program will explain to declare and then initialize an int variable.public static void main(String[] args) {int data1;data1

Variable and Data Type in Java

Filed under: Java Tutorial on 2024-03-01 20:43:00
VariableVariables occupy the memory to store data for a particular time. Data Type A data type is used to identify the size and type of information stored in a variable. Data types help in memory management. It helps to assign thememory depending upon the type of data type. Most importantl

First Program in Java

Filed under: Java Tutorial on 2024-03-01 20:39:53
This Java program has been developed to display the text 'Hello Planet!' onthe console screen.// File-Name: Hello.javapublic class Hello {     public static void main(String[] args) {     // Displaying "Hello Planet!" on the console     System.out.println

what is JDK, JRE, Garbage Collector and Classpath in Java

Filed under: Java Tutorial on 2024-03-01 16:56:07
Java Development Kit (JDK): Overview: The JDK is a comprehensive package for Java development. It encompasses essential components like the compiler, Java Runtime Environment (JRE), Java debuggers, documentation, and more. To write, compile, and run Java programs, it's imperative to install the

Program to Serialize Student Deserialize student object in Java

Filed under: Java on 2024-03-01 06:48:15
// Program to Serialize Student Deserialize student object.import java.io.*;class Student implements Serializable{int rno;String sname;double marks; // ConstructorStudent( int r, String nm, double m ){ rno = r; sname = nm; marks = m;}void display(){ System.out.println(" Roll

Program to Serialize Student object in Java

Filed under: Java on 2024-03-01 06:47:34
// Program to Serialize Student object student object.import java.io.*;class Student implements Serializable{int rno;String sname;double marks; // ConstructorStudent( int r, String nm, double m ){ rno = r; sname = nm; marks = m;}void display(){ System.out.println(" Roll No. 

Program to De-serialize object of Box class in Java

Filed under: Java on 2024-03-01 06:46:15
// Program to De-serialize object of Box class.import java.io.*;import java.util.*;// Box classclass Box  implements  Serializable{// instance variablesprivate double width;private double height;private double depth;// default constructorBox(){ width = 0; height = 0; depth =

Program to Serialize object of Box class in Java

Filed under: Java on 2024-03-01 06:45:40
// Program to Serialize object of Box class.import java.io.*;import java.util.*;// Box classclass  Box  implements Serializable{// instance variablesprivate double width;private double height;private double depth;// default constructorBox(){ width = 0; height = 0; depth = 0;

Program to read data from text file using FileReader in Java

Filed under: Java on 2024-03-01 06:44:32
// Program to read data from text file using // FileReader  and display it on the monitor.import java.io.*;class FileReaderDemo{public static void main( String args[ ] ) throws IOException{ // attach file to FileReader FileReader fr = null; try {  fr = new FileRead

What is Bytecode in the Development Process

Filed under: Java on 2024-02-27 15:43:54
Description: During the development process, Java source code is compiled into a special format called bytecode by the Javac compiler found in the Java Development Kit (JDK). This bytecode can be executed by the JVM and is saved with a .class extension.

What is Java Virtual Machine (JVM)?

Filed under: Java on 2024-02-27 15:42:54
Definition: The JVM is a critical component in the world of Java programming. It serves two primary functions: enabling Java applications to run across various devices and operating systems (the "Write once, run anywhere" principle) and efficiently managing and optimizing program memory. Technical D

Create a method named calc, which accepts an integer (int), a character (char) and one more integer (int), and depending on the character, returns the result

Filed under: Java on 2024-02-27 13:59:41
Create a method named calc, which accepts an integer (int), a character (char) and one more integer (int), and depending on the character, returns the result of the corresponding operation on numbers:'+' — sum of integers'-' — integer difference (first minus second)'*' — product of integers'/'

Event Types in Node Js

Filed under: NodeJs on 2024-02-22 21:01:23
Sr.No.Events & Description1newListener1. event − String: the event name2. listener − Function: the event handler functionThis event is emitted any time a listener is added. When this event is triggered, the listener may not yet have been added to the array of listeners for the event.2removeL

Event Emitter Pattern in Node Js

Filed under: NodeJs on 2024-02-22 20:51:05
AIM:To demonstrate the event emitter patternObjective:Explanation of event emitter pattern with programme.Theory:The EventEmitter is a module that facilitates communication/interaction between objects in Node. EventEmitter is at the core of Node asynchronous event-driven architecture. Many of Node

Standard Callback Pattern in Node Js

Filed under: NodeJs on 2024-02-22 20:46:50
AIM: To demonstrate the use of Standard callback pattern Objective: Node js callback pattern function callback Theory: Callback is an asynchronous equivalent for a function. A callback function is called at the completion of a given task. Node makes heavy use of callbacks. All the APIs of 

Node.js – Console

Filed under: NodeJs on 2024-02-22 20:42:55
Node.js console is a global object and is used to print different levels of messages to stdout and stderr. There are built-in methods to be used for printing informational, warning, and error messages. It is used in synchronous way when the destination is a file or a terminal and in asynchronous way

Node.js - REPL Terminal

Filed under: NodeJs on 2024-02-22 20:38:39
REPL stands for Read Eval Print Loop and it represents a computer environment like a Windows console or Unix/Linux shell where acommand is entered and the system responds with an output in an interactive mode. Node.js or Node comes bundled with a REPLenvironment. It performs the following tasks −R

Traditional Web Server Model

Filed under: NodeJs on 2024-02-22 16:28:21
The traditional web server model consists of a pool of threads which may process requests. Each time a new request comes in, it is assigned to a different thread in the pool. In the event a request is received and a thread is not available, the request will have to wait until a previous request fini

How to Install Node.js and NPM on Windows

Filed under: NodeJs on 2024-02-22 16:25:43
In a web browser, navigate to https://nodejs.org/en/download/. Click the Windows Installer button to download the latest default version. At the time this article was written, version 10.16.0-x64 was the latest version. The Node.js installer includes the NPM package manager.Step 2: Install Node.js a

What is Node.js Process Model

Filed under: NodeJs on 2024-02-22 16:22:25
The Node.js process model differs from traditional web servers in that Node.js runs in a single process with requests being processed on a single thread. One advantage of this is that Node.js requires far fewer resources. When a request comes in, it will be placed in an event queue. Node.js uses an 

Advantage of Node Js

Filed under: NodeJs on 2024-02-22 16:20:16
The ability to scale up quickly: Each of the nodes in Node.js is based around an “event.” A customer buys an in-app purchase, or sends an email to customer service, for instance. The amount of nodes you can add to your core programming function are nearly limitless. This means you can scale vert

What is Node Js?

Filed under: NodeJs on 2024-02-22 16:18:35
It is a free, open-source, cross-platform runtime environment that runs on JavaScript. Meant mainly for the server side, or client side, of a mobile application, it is a full-stack development environment that divides up tasks into fully separate “nodes.”When people ask, “what are the advantag

Ball Game example In Java

Filed under: Java on 2024-02-16 10:05:17
In this example, i have shown you an example which have mainly three classes:BallGame.javaBallGameImpl.javaApp.javaWhat does this game does?In this game, you will fill the no. of players and no. of balls. Then this game will distribute these balls among the players. After distribution it will tell h

How to update vscode .deb in ubuntu?

Filed under: Coding on 2024-01-16 19:39:28
To update Visual Studio Code (VSCode) on Ubuntu using the .deb package, you can follow these steps:you can manually download the latest .deb package from the VSCode website, and then install it using the following steps:Download the Latest .deb Package:Go to the VSCode website and download the lates

Unit-6: Functions | BCA semester 1

Filed under: BCA Study Material on 2023-10-31 09:08:27
basic types of functionIn C programming, there are two basic types of functions:Library functions: These are the built-in functions in C that are included in the C library. For example, printf, scanf, strcpy, etc. Library functions are used to perform specific tasks, such as reading from the standar

Unit-3: Control structures : BCA semester 1

Filed under: BCA Study Material on 2023-10-30 07:39:03
Control structures in C programming allow you to control the flow of execution of your program based on conditions or repetition. There are three main control structures in C:Conditional (if-else) statements: These are used to execute a block of code only if a certain condition is met.Example:int x 

Java program to sort an array in ascending order

Filed under: Java on 2023-10-29 09:53:28
In this java program, we are reading total number of elements (N) first, and then according the user input (value of N)/total number of elements, we are reading the elements. Then sorting elements of array in ascending order and then printing the elements which are sorted in ascending order.Programi

Java String compareTo() Example Code

Filed under: Java on 2023-10-26 21:45:31
class Main { public static void main(String[] args) {   String str1 = "Learn Java";   String str2 = "Learn Java";   String str3 = "Learn Kolin";   int result;   // comparing str1 with str2   result = str1.compareTo(str2);   S

Java String split() Example

Filed under: Java on 2023-10-26 21:42:57
class Main { public static void main(String[] args) {   String text = "Java is a fun programming language";   // split string from space   String[] result = text.split(" ");   System.out.print("result = ");   for (String str : result) {  &n

Program to use File class and its methods in Java

Filed under: Java on 2023-10-25 06:51:37
//  Program to use File class and its methodsimport java.io.*;class FileDemo{   public static void main(String args[ ])    {       File f = new File("FileDemo.java");       System.out.println("File : " + f.getName() + (f.isFile() 

Program to use URLConnection class in Java

Filed under: Java on 2023-10-25 06:49:31
//  Program to use URLConnection class.import java.io.*;import java.net.*;import java.util.Date;class URLConnectionDemo{public static void main(String args[ ]) throws Exception{ int ch; URL ob = new URL("http://www.bethedeveloper.com/java/"); URLConnection uc = u.openConnection()

Program to display all parts of URL in Java

Filed under: Java on 2023-10-25 06:48:59
// Program to display all parts of URL.import java.net.*;class URLDemo{public static void main( String args[ ] ) throws Exception{ URL ob = new URL("http://www.bethedeveloper.com/java/"); System.out.println(" Protocol : " + ob.getProtocol()); System.out.println(" Host : " + ob.getHost

Program to Display host name by IP address in Java

Filed under: Java on 2023-10-25 06:48:30
// Program to Display host name by IP address.import java.net.*;class HostName{public static void main( String args[ ] ) { // byte ad[ ] = { (byte)192, (byte)168, 1, 2 };  try {  // InetAddress ip = InetAddress.getByAddress( ad );  InetAddress ip = InetAddress.getB

Program to create Menu in AWT in Java

Filed under: Java on 2023-10-25 06:47:10
//  Program to create Menu in AWT.import java.awt.*;import java.applet.*;import java.awt.event.*;class MyMenu extends Frame implements ActionListener{String str="";CheckboxMenuItem cmiBold , cmiItalic;MenuItem miNew , miOpen , miSave, miCut, miCopy, miPaste, miRed, miGreen, miBlue;MyMenu(){&nbs

Program to explain Dialog class in Java

Filed under: Java on 2023-10-25 06:46:42
//  Program to explain Dialog class.import java.applet.*;import java.awt.*;import java.awt.event.*;class MyDialog extends Dialog implements ActionListener{  Button b1;  Label l1;    MyDialog( Frame f, String s, boolean u )  { super( f, s, u ); setLayout( 

Program to use GridBagLayout in Java

Filed under: Java on 2023-10-25 06:46:11
// Program to use GridBagLayout.import java.awt.*;import java.awt.event.*;public class GridBagLayoutDemo1 extends Frame{GridBagLayout gb;GridBagConstraints gbc;Button b1, b2, b3, b4, b5, b6, b7;public GridBagLayoutDemo1( String s ){ super( s );    gb = new GridBagLayout(); g

Program to explain CardLayout in Java

Filed under: Java on 2023-10-25 06:45:42
//  Program to explain CardLayout.import java.awt.*;import java.awt.event.*;import java.applet.*;/*<applet code="CardLayoutDemo" width=300 height=100></applet>*/public class CardLayoutDemo extends Applet implements ActionListener, MouseListener {Button b1, b2, b3, b4, b5;Panel 

Program to use GridLayout in Java

Filed under: Java on 2023-10-25 06:45:00
//  Program to use GridLayout.import java.awt.*;import java.awt.event.*;import java.applet.*;/*<applet code="GridLayoutDemo" width="300" height="150"></applet>*/public class GridLayoutDemo extends Applet {Button b1, b2, b3, b4, b5;public void init() { setLayout(new Gr

Program to use Insets in Java

Filed under: Java on 2023-10-25 06:44:35
// Program to use Insets.import java.awt.*;import java.awt.event.*;import java.applet.*;/*<applet code="InsetsDemo" width="300" height="150"></applet>*/public class InsetsDemo extends Applet {Button b1, b2, b3, b4, b5;public void init() { setLayout(new BorderLayout());&nbs

Program to use BorderLayout in Java

Filed under: Java on 2023-10-25 06:44:03
//  Program to use BorderLayout.import java.awt.*;import java.awt.event.*;import java.applet.*;/*<applet code="BorderLayoutDemo" width="300" height="150"></applet>*/public class BorderLayoutDemo extends Applet {Button b1, b2, b3, b4, b5;public void init() { setLayout(

Program to use FlowLayout in Java

Filed under: Java on 2023-10-25 06:43:36
//  Program to use FlowLayout.import java.awt.*;import java.awt.event.*;import java.applet.*;/*<applet code="FlowLayoutDemo" width="300" height="150"></applet>*/public class FlowLayoutDemo extends Applet {Button b1, b2, b3, b4, b5;public void init() { setLayout(new Fl

Program to use Scrollbar AWT control in Java

Filed under: Java on 2023-10-25 06:43:08
//  Program to use Scrollbar AWT control.import java.awt.*;import java.awt.event.*;import java.applet.*;/*<applet code="ScrollbarDemo" width="250" height="150"></applet>*/public class ScrollbarDemo extends Applet implements AdjustmentListener, MouseMotionListener {String msg = 

Program to use List AWT control in Java

Filed under: Java on 2023-10-25 06:42:37
//  Program to use List AWT control.import java.awt.*;import java.awt.event.*;import java.applet.*;/*<applet code="ListDemo" width=300 height=150></applet>*/public class ListDemo extends Applet implements ActionListener {List os, browser;String msg = "";public void init() 

Program to use Choice AWT control in Java

Filed under: Java on 2023-10-25 06:42:11
//  Program to use Choice AWT control.import java.awt.*;import java.awt.event.*;import java.applet.*;/*<applet code="ChoiceDemo" width="300" height="150"></applet>*/public class ChoiceDemo extends Applet implements ItemListener {Choice os, browser;String msg = "";public void in

Program to use CheckboxGroup ( RadioButton ) AWT control in Java

Filed under: Java on 2023-10-25 06:41:41
//  Program to use CheckboxGroup ( RadioButton ) AWT control.import java.awt.*;import java.awt.event.*;import java.applet.*;/*<applet code="RadioButtonDemo" width="250" height="100"></applet>*/public class RadioButtonDemo extends Applet implements ItemListener {String msg = "";

Program to use Checkbox AWT control in Java

Filed under: Java on 2023-10-25 06:40:54
// Program to use Checkbox AWT control.import java.awt.*;import java.awt.event.*;import java.applet.*;/*<applet code="CheckBoxDemo" width="250" height="150"></applet>*/public class CheckBoxDemo extends Applet implements ItemListener {String msg = "";Checkbox cbRed, cbGreen, cbBlue;p

Program to use TextArea AWT control in Java

Filed under: Java on 2023-10-25 06:40:28
//  Program to use TextArea AWT control.import java.awt.*;import java.applet.*;/*<applet code="TextAreaDemo" width="300" height="200"></applet>*/public class TextAreaDemo extends Applet {public void init() { String val =  "Java SE 6 is the latest version of the m

Program to use TextField AWT control in Java

Filed under: Java on 2023-10-25 06:39:56
// Program to use TextField AWT control.import java.awt.*;import java.awt.event.*;import java.applet.*;/*<applet code="TextFieldDemo" width=350 height=150></applet>*/public class TextFieldDemo extends Applet implements ActionListener {TextField tfname, tfpass;public void init() 

AWT frame class example in Java

Filed under: Java on 2023-10-25 06:39:22
//  Program to use Frame class.import java.awt.*;import java.awt.event.*;public class FrameTest extends Frame implements ActionListener{TextField tf;Button b;String s = "";   public  FrameTest(){ tf = new TextField( 10 ); b = new Button( "Show" );  add( "North

AWT button example in Java

Filed under: Java on 2023-10-25 06:38:57
//  Program to use Button  AWT control.import java.awt.*;import java.awt.event.*;import java.applet.*;/*<applet code="ButtonDemo" width=250 height=150></applet>*/public class ButtonDemo extends Applet implements ActionListener {String msg = "";Button b1, b2, b3;public void

AWT Label example in Java

Filed under: Java on 2023-10-25 06:38:35
// Program to use Label  AWT control.import java.awt.*;import java.applet.*;/*<applet code="LabelDemo" width=300 height=100></applet>*/public class LabelDemo extends Applet {public void init() { Label l1 = new Label("Java"); Label l2 = new Label("Programming");&n

Program to use Window Event in Java

Filed under: Java on 2023-10-19 07:07:54
//  Program to use Window Event.import java.awt.*;import java.awt.event.*;public class WindowEventDemo extends Frame implements WindowListener{public WindowEventDemo(){ addWindowListener( this ); setSize( 250, 150 ); setVisible( true );}public void windowOpened( WindowEvent we ){

Program to expain Fucus Event in Java

Filed under: Java on 2023-10-19 07:07:22
//  Program to expain Fucus Event.import java.awt.*;import java.awt.event.*;import java.applet.*;/*<applet code="FocusEventDemo" width="200" height="100"></applet>*/public class FocusEventDemo extends Applet implements FocusListener{Button b1, b2, b3;Label l1, l2;public void init(){

Program to use MouseAdapter class as Inner class in Java

Filed under: Java on 2023-10-19 07:05:55
//  Program to use MouseAdapter class as Inner class.import java.applet.*;import java.awt.event.*;/*<applet code="MouseAdapterInnerTest" width="300" height="100"></applet>*/public class MouseAdapterInnerTest extends Applet {public void init() { addMouseListener(new My

Program to use MouseAdapter class in Java

Filed under: Java on 2023-10-19 07:05:02
//  Program to use MouseAdapter class.import java.applet.*;import java.awt.event.*;/*<applet code="MouseAdapterTest" width="200" height="100"></applet>*/public class MouseAdapterTest extends Applet {public void init() { addMouseListener(new MyMouseAdapter(this));}}cla

Program to explain Key Event with Virtual Key in Java

Filed under: Java on 2023-10-19 07:04:19
//  Program to explain Key Event with Virtual Key.import java.awt.*;import java.awt.event.*;import java.applet.*;/*<applet code="KeyEventTest1" width="300" height="100"></applet>*/public class KeyEventTest1 extends Applet implements KeyListener {String msg = "";int X = 10, Y = 

Program to explain Key Event in Java

Filed under: Java on 2023-10-19 07:03:47
//  Program to explain Key Event.import java.awt.*;import java.awt.event.*;import java.applet.*;/*<applet  code="KeyEventTest"  width="300" height="200"></applet>*/public class KeyEventTest extends Applet implements KeyListener {String msg = "";int X = 10, Y = 20;&nbs

Program to explain Mouse Event and Mouse Motion Event in Java

Filed under: Java on 2023-10-19 07:03:14
//  Program to explain Mouse Event and Mouse Motion Event.import java.awt.*;import java.awt.event.*;import java.applet.*;/*<applet  code="MouseEventTest"  width="300" height="200"></applet>*/public class MouseEventTest extends Applet implements  MouseListener, MouseMo

Program to explain Mouse Motion Event in Java

Filed under: Java on 2023-10-19 07:02:42
//  Program to explain Mouse Motion Event.import java.awt.*;import java.awt.event.*;import java.applet.*;/*<applet  code="MouseMotionEventTest" width="300" height="200"></applet>*/public class MouseMotionEventTest extends Applet implements MouseMotionListener {String msg =

Program to explain Mouse Event in Java

Filed under: Java on 2023-10-19 07:01:58
//  Program to explain Mouse Event.import java.awt.*;import java.awt.event.*;import java.applet.*;/*<applet  code="MouseEventTest1"  width="300" height="200"></applet>*/public class MouseEventTest1 extends Applet implements MouseListener {String msg = "";int mouseX = 

Program to change color using setColor() method in Java

Filed under: Java on 2023-10-16 07:07:57
//  Program to change color using setColor() method.import java.awt.*;import java.applet.*;/*<applet code="GraphicsColor" width="300" height="200"></applet>*/public class  GraphicsColor  extends  Applet {public void paint(Graphics g) { Color c1 = new Co

Program to change Font using setFont() method in Java

Filed under: Java on 2023-10-16 07:07:16
//  Program to change Font using setFont() method.import java.awt.*;import java.applet.*;/*<applet code="DrawStringFontTest1a" width="200" height="100" ></applet>*/public class  DrawStringFontTest1a  extends Applet  {Font f;public void init() { setBackground

Program to draw Arc in Applet using fillArc() method in Java

Filed under: Java on 2023-10-16 07:06:07
// Program to draw Arc in Applet using fillArc() method.import java.awt.*;import java.applet.*;/*<applet code="FillArcTest1a" width="200" height="100" ></applet>*/public class  FillArcTest1a  extends  Applet  {public void paint(Graphics g) { setBackground( C

Program to draw Arc in Applet using drawArc() method in Java

Filed under: Java on 2023-10-16 07:05:37
// Program to draw Arc in Applet using drawArc() method.import java.awt.*;import java.applet.*;/*<applet code="DrawArcTest1a" width="200" height="100" ></applet>*/public class DrawArcTest1a extends Applet  {public void paint(Graphics g) { setBackground( Color.yellow );&nbs

Program to draw oval in Applet using drawOval() method in Java

Filed under: Java on 2023-10-16 07:04:38
//  Program to draw oval in Applet using drawOval() method.import java.awt.*;import java.applet.*;/*<applet code="DrawOvalTest1a" width="200" height="100" ></applet>*/public class DrawOvalTest1a extends Applet  {public void paint(Graphics g) { setBackground( Color.yel

Program to draw line in Frame using drawLine() method in Java

Filed under: Java on 2023-10-16 07:02:07
//  Program to draw line in Frame using drawLine() method.import java.awt.*;public class DrawLineTest1b  extends  Frame  {public DrawLineTest1b(){ setSize(200, 200); setVisible(true);}public void paint(Graphics g) { g.drawLine(20, 40, 180, 180);}public static 

Program to use Thread without Synchronization in Java

Filed under: Java on 2023-10-16 06:50:51
//  Program to use Thread without Synchronization.class Shared{void justDoIt( String s ){ System.out.println( " Starting ::: " + s ); try {  Thread.sleep( 500 ); } catch( InterruptedException e )  { } System.out.println( " Ending ::: " + s );}}class 

Program to use suspend( ) and resume( ) method in Java

Filed under: Java on 2023-10-16 06:48:35
// Program to use suspend( ) and resume( ) method.class NewThread implements Runnable{String tn;Thread t;NewThread( String tname ){ tn = tname; t = new Thread( this, tn ); System.out.println( " New Thread ::: " + t ); t.start();}public void run(){ try {  for( int i

Python program to print formatted string

Filed under: Python on 2023-09-23 06:44:48
print("""a string that you "don't" have to escapeThisis a  ....... multi-lineheredoc string --------> example""")      Output:a string that you "don't" have to escape                                

Program to use setPriority( ) method of Thread in Java

Filed under: Java on 2023-09-22 06:48:31
//  Program to use setPriority( ) method.class A extends Thread{public void run(){ for( int i=1 ; i<=10 ; i++ ) {       System.out.println( " THREAD A = " + i ); } System.out.println( " END OF THREAD A." );}}class B extends Thread{public void run(){&nb

Program to extend multiple classes from Thread class in Java

Filed under: Java on 2023-09-22 06:47:47
//  Program to extend multiple classes from Thread class.class A extends Thread{public void run(){ for( int i=1 ; i<=10 ; i++) {  System.out.println( " Java" ); }}}class B extends Thread{public void run(){ for( int i=1 ; i<=10 ; i++) {  System.out.printl

Java Program to explain Main thread and currentThread( ) method

Filed under: Java on 2023-09-22 06:46:01
// Program Main thread and currentThread( ) methodclass CurrentThread{public static void main( String args[ ] ){ Thread t = Thread.currentThread(); System.out.println( "Current Thread is = " + t ); t.setName( "My Thread" ); System.out.println( "After Changing Name is = " + t );}}

C# program to check whether a character is vowel or consonant

Filed under: C# on 2023-09-22 06:42:40
Here you will find an algorithm and program in C# programming language to check whether the given character is vowel or consonant.Explanation : In English, five alphabets A, E, I, O, and U are called as Vowels. In English, all alphabets other than vowels are Consonant. Algorithm to check whethe

C# Program to Print Fibonacci Series upto N terms

Filed under: C# on 2023-09-21 06:59:51
Here you will find an algorithm and program in C# programming language to print fibonacci series. First let us understand what fibonacci series means.Explanation : The Fibonacci sequence is a sequence consisting of a series of numbers and each number is the sum of the previous two numbers. For Examp

C# program to swap two numbers without using temporary variable

Filed under: C# on 2023-09-21 06:58:23
Here you will find an algorithm and program in C# programming language to swap 2 numbers without using any third or temporary variable.Swapping two number : Swap two numbers means exchange the values of two variables with each other. Suppose we are given 2 numbers num1 = 10 and num2 = 20 and we have

C# Program to Find the Sum of Digits in a Given Number

Filed under: C# on 2023-09-21 06:56:45
Here you will find an algorithm and program in C# programming language to find the sum of digits in number. Now let us understand this.Explanation : Suppose we are having number 12548 and we have to calculate the sum of digits in the given number, so here we have the following digits 1, 2, 5, 4, 8 a

C# Program to Count the Number of Digits in a Number

Filed under: C# on 2023-09-21 06:55:39
Here you will find an algorithm and program in C# programming language to count number of digits in a number. First let us understand this.Explanation : Suppose an input number is given as 12341 then the output will be 5 as there are 5 digits in the given number and digits are 1, 2, 3, 4, 1.Algorith

C# Program to Check Whether the Given Year is Leap Year or Not

Filed under: C# on 2023-09-21 06:54:20
Here you will find an algorithm and program in C# programming language to check whether the given year is leap year or not. First let us understand what is leap year?Explanation : A leap year is a calendar year that contains an additional day added to keep the calendar year synchronized. A leap year

C# program to check whether the given number N is even or odd

Filed under: C# on 2023-09-21 06:52:53
Here you will find an algorithm and program in C# programming language to check whether the given number is even or odd number. First let us understand what is even number and odd number.Explanation : If the number is divisible by 2 then the number is even number and if the number is not divisible b

C# Program to Display Hello World on Screen

Filed under: C# on 2023-09-21 06:50:25
Here you will find an algorithm and program in C# programming language to print Hello World on screen. The "Hello World" program is the first step towards learning any programming language and also one of the simplest programs you will learn. All you have to do is display the message "Hello World" o

Program 2 to create Applet with param tag in Java

Filed under: Java on 2023-09-20 06:41:28
//  Program to create Applet with param tag.import java.awt.*;import java.applet.Applet;/*<applet  code="AppletTest3.class" width="300" height="60"><param name="msg" value="Let's learn Applet.">  </applet>*/public class AppletTest3 extends Applet {String msg = "

Program to create Applet with param tag in Java

Filed under: Java on 2023-09-20 06:40:46
// Program to create Applet with param tag.import java.awt.*;import java.applet.Applet;/*<applet code="AppletTest2b.class" width="300" height="100"><param name="message" value="BIIT Computer Education" /></applet>*/public class  AppletTest2b  extends  Applet {St

Program to use Applet with Button and it's event in Java

Filed under: Java on 2023-09-20 06:39:13
// Program to use Applet with Button and it's event.import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.applet.Applet;import java.awt.Button;/*<applet code="AppletTest2.class" width="300" height="100"></applet>*/public class AppletTest2 extends Applet 

Program to use getCodeBase() and getDocumentBase() in Java

Filed under: Java on 2023-09-20 06:38:44
// Program to use getCodeBase() and getDocumentBase().import java.awt.*;import java.applet.*;import java.net.*;/*<applet code="Applet07" width="300" height="50"></applet>*/public class  Applet07  extends Applet{public void paint(Graphics g) { String msg;  UR

Program with param tag in applet tag in Java

Filed under: Java on 2023-09-20 06:38:12
//  Program with param tag in applet tag.import java.awt.*;import java.applet.*;/*<applet code="Applet06" width="300" height="50"><param name="message" value="Java makes the Web move!"></applet>*/public class  Applet06 extends Applet implements Runnable {String 

Program to display string in Status window in Java

Filed under: Java on 2023-09-20 06:36:38
//  Program to display string in Status window.import java.awt.*;import java.applet.*;/*<applet code="Applet04" width="300" height="50"></applet>*/public class Applet04 extends  Applet{public void init() { setBackground(Color.yellow);}public void paint(Graphics g)&nbs

Program with Banner applet in Java

Filed under: Java on 2023-09-20 06:36:06
// Program with Banner applet.import java.awt.*;import java.applet.*;/*<applet code="Applet03" width="300" height="50"></applet>*/public class  Applet03 extends Applet implements Runnable {String msg = "Java Programming Examples";Thread t = null;boolean flag;public void in

Program to use Applet with init(), start() and paint() in Java

Filed under: Java on 2023-09-20 06:35:34
// Program to use Applet with init(), start() and paint().import java.applet.Applet;import java.awt.*;/*<applet  code="AppletTest1.class" width="300" height="100"></applet>*/public class AppletTest1 extends  Applet {String msg = "";public void init() { setBackgro

Program to use Applet Program and it's Life Cycle in Java

Filed under: Java on 2023-09-20 06:34:59
// Program to use Applet Program and it's Life Cycle.import java.awt.*;import java.applet.*;/*<applet code="Applet01" width="300" height="200"></applet>*/public class  Applet01  extends  Applet {public void init() { setBackground(Color.yellow); System.o

Program to use Boolean Wrapper class in Java

Filed under: Java on 2023-09-19 08:09:43
// Program to use Boolean Wrapper classclass  WrapperBoolean{public static void main( String args[ ] ){ Boolean b1 = new Boolean(false); Boolean b2 = new Boolean("true"); System.out.println(b1.booleanValue()); System.out.println(b2.booleanValue());}}Output:falsetrue

Program to use expression with Wrapper classes in Java

Filed under: Java on 2023-09-19 08:09:17
//  Program to use expression with Wrapper classes.class Wrapper5{public static void main(String args[ ]) { Integer iOb = 100; Double dOb = 123.45; dOb = dOb + iOb; System.out.println("dOb after expression: " + dOb);}}Output:dOb after expression: 223.45

Program to use Simple Wrapper Class in Java

Filed under: Java on 2023-09-19 08:07:19
//  Program to use Simple Wrapper Class.class  Wrapper1{public static void main( String args[ ] ){ // Boxing Integer  iOb = new Integer(100); // Unboxing int i = iOb.intValue(); System.out.println(i + " : " + iOb); }}Output:100 : 100

Program to use enum in an application in Java

Filed under: Java on 2023-09-19 08:06:50
//  Program to use enum in an application.import java.util.Random;enum  Answers {NO, YES, MAYBE, LATER, SOON, NEVER}class Question {Random rand = new Random();Answers ask() { int prob = (int) (100 * rand.nextDouble()); if (prob < 15)  return Answers.MAYBE; 

Comparison in Enum example in Java

Filed under: Java on 2023-09-19 06:56:08
// Program to explain that enum has Ordinal// number that is used in comparison.enum  Colour {Red, Green, Blue, Black, White, Orange, Yellow}class  EnumDemo4 {public static void main(String args[ ]){ Colour c1, c2, c3; // Obtain all ordinal values using ordinal(). 

Program to use Java Enum as a Class type in Java

Filed under: Java on 2023-09-19 06:55:19
//  Program to use Java Enum as a Class type.enum Colour {Red(200), Green(150), Blue(100), Black(250), White(175), Orange(225), Yellow(125);private int price;   // price of each colourColour(int p) {  price = p; }int getPrice() {  return price; 

Java Program to use values() and valueOf() methods of Enum

Filed under: Java on 2023-09-19 06:52:39
//  Program to use values() and valueOf() methods of Enum.enum Colour {Red, Green, Blue, Black, White, Orange, Yellow}class EnumDemo2 {public static void main(String args[ ]){ Colour c1;  System.out.println("All Colour constants: "); Colour  clr[ ] = Colour.va

Program to use Enumeration Named Constants in Java

Filed under: Java on 2023-09-19 06:51:52
//  Program to use Enumeration Named Constants.enum Colour {Red, Green, Blue, Black, White, Orange, Yellow}class EnumDemo1 {public static void main(String args[ ]){ Colour c1; c1 = Colour.Red; System.out.println("Value of c1: " + c1); c1 = Colour.Blue; if(c1 =

Chained exception example in Java

Filed under: Java on 2023-09-19 06:50:25
//  Program to explain Chained Exception.class  ChainedException{static void demoproc() { NullPointerException e = new NullPointerException("top layer"); e.initCause(new ArithmeticException("cause")); throw e;}public static void main(String args[ ]) { try 

User defined exception example 2 in Java

Filed under: Java on 2023-09-19 06:50:00
//  Program to create User-defined Exception//  for checking validity of number for Square root.class NegativeNumberException extends Exception {private double num;NegativeNumberException(double n) { num = n;}public String toString() { return "Square root of " + nu

User defined exception example in Java

Filed under: Java on 2023-09-19 06:49:36
// Program to create User-defined Exception// for checking validity of age.class InvalidAgeException extends Exception {private int age;InvalidAgeException(int a) { age = a;}public String toString() { return "Age: " + age + " is not a valid age.";}}class  Exception14&nb

Finally block example in Java

Filed under: Java on 2023-09-19 06:49:11
// Program to use finally Block with exception handling.class  finallyBlockWithException{// Through an exception out of the method.static void procA() { try  {  System.out.println("inside procA");  throw new RuntimeException("demo"); }  finally 

Throw statement example in Java

Filed under: Java on 2023-09-19 06:48:47
//  Program to use throw statement to raise exception and rethrow the exception.class  ThrowExceptionExample {static void demoproc() { try  {  throw new NullPointerException("demo"); }  catch(NullPointerException e)  {  System.out

Nested try catch block with function example in Java

Filed under: Java on 2023-09-19 06:48:23
// Program to explain Nested Try-Catch Block with Function.class  NestedTryCatchWithFunction{static void nesttry(int a) { try  {  if(a==1)    a = a / (a-a);  if(a==2)   {   int c[ ] = { 1 };   c[10] = 100;  } }

Nested try catch block example in Java

Filed under: Java on 2023-09-19 06:47:47
//  Program to explain Nested Try-Catch Block.class NestedTryCatch{public static void main(String args[ ]) { try  {  int a = args.length;  int b = 10 / a;  System.out.println("a = " + a);  try   {    if(a==1)     a 

Order of exception subclass and superclass in Java

Filed under: Java on 2023-09-19 06:47:05
//Program to explain that, when we use multiple catch statements, it is //important to remember that exception subclasses must come before any of their superclasses.class  MultipleException{public static void main(String args[ ]) { try  {  int a = 0;  int b = 

Multiple exceptions in single catch block example in Java

Filed under: Java on 2023-09-19 06:45:58
// Program to catch Multiple exceptions in single Catch Block.class  Exception6{public static void main(String args[ ]) { try  {  int a = args.length;  System.out.println("a = " + a);  int b = 10 / a;  int c[] = { 1 };  c[10] = 100; }  

Multiple catch block example in Java

Filed under: Java on 2023-09-19 06:45:13
// Program to use Multiple Catch Block with Exception.class Exception05 {public static void main(String args[ ]) { try  {  int a = args.length;  System.out.println("a = " + a);  int b = 10 / a;  int c[ ] = { 1 };  c[10] = 100; }  catch

Try and catch example in Java

Filed under: Java on 2023-09-19 06:44:48
//  Simple try and catch example for exception handlingclass  SimpleTryCatchExample {public static void main(String args[ ]) { int d, a; try  {   d = 0;  a = 10 / d;  System.out.println("This will not be printed."); }  catch 

Stack trace of default Exception Handler of JVM

Filed under: Java on 2023-09-19 06:44:23
// Program without Exception Handling and // stack trace of Default Handler of JVM.class  DefaultException2 {static void subroutine() { int d = 0; int a = 10 / d;}public static void main(String args[ ]) { Exception02.subroutine();}}Output:Exception in thread "

Default Exception Handler of JVM

Filed under: Java on 2023-09-19 06:43:44
// Simple  Program without Exception Handling and // use of Default Handler of JVM.class  DefaultException{public static void main(String args[ ]) { int  d = 0; int  a = 10 / d; // here JVM automatiically handle exaception}}Output:Exception in thread "mai

program to display the examination schedule

Filed under: Python on 2023-09-18 06:58:11
Python program to display the examination schedule. (extract the date from exam_st_date).exam_st_date = (11, 12, 2014)Sample Output: The examination will start from : 11 / 12 / 2014 Code:exam_st_date = (11,12,2014)print( "The examination will start from : %i / %i / %i"%exam_st_date)   &nbs

Python program which takes radius from user and print area

Filed under: Python on 2023-09-18 06:50:25
#Write a Python program which accepts the radius of a circle from the user and compute the area Python: Area of a CircleIn geometry, the area enclosed by a circle of radius r is πr2. Here the Greek letter π represents a constant, approximately equal to 3.14159, which is equal to the ratio of 

Python code to find sum of elements in given array

Filed under: Python on 2023-09-17 22:28:23
#!/usr/bin/python# -*- coding: utf-8 -*-# Python 3 code to find sum# of elements in given arraydef _sum(arr):   # initialize a variable   # to store the sum   # while iterating through   # the array later   sum = 0   # iterate through the a

Python program for implementation of Bubble Sort

Filed under: Python on 2023-09-17 22:27:52
#!/usr/bin/python# -*- coding: utf-8 -*-# Python program for implementation of Bubble Sortdef bubbleSort(arr):   n = len(arr)   # Traverse through all array elements   for i in range(n - 1):   # range(n) also work but outer loop will repeat one time more than 

Python program for implementation of Quicksort Sort

Filed under: Python on 2023-09-17 22:27:24
#!/usr/bin/python# -*- coding: utf-8 -*-# Python program for implementation of Quicksort Sort# This function takes last element as pivot, places# the pivot element at its correct position in sorted# array, and places all smaller (smaller than pivot)# to left of pivot and all greater elements to righ

Python program to swap first and last element of a list

Filed under: Python on 2023-09-17 22:25:39
#!/usr/bin/python# -*- coding: utf-8 -*-# Python3 program to swap first# and last element of a list# Swap functiondef swapList(newList):   size = len(newList)   # Swapping   temp = newList[0]   newList[0] = newList[size - 1]   newList[size - 1] = tem

Python program to find maximum in arr[] of size n

Filed under: Python on 2023-09-17 22:24:05
#!/usr/bin/python# -*- coding: utf-8 -*-# Python3 program to find maximum# in arr[] of size n# python function to find maximum# in arr[] of size ndef largest(arr, n):   # Initialize maximum element   max = arr[0]   # Traverse array elements from second   # and

Python Program to check if a string is palindrome or not

Filed under: Python on 2023-09-17 22:02:50
#!/usr/bin/python# -*- coding: utf-8 -*-# Program to check if a string is palindrome or notmy_str = 'aibohphobia'# make it suitable for caseless comparison# reverse the stringrev_str = reversed(my_str)# check if the string is equal to its reverseif list(my_str) == list(rev_str):   print 'T

Python program to find H.C.F of two numbers

Filed under: Python on 2023-09-17 22:02:23
#!/usr/bin/python# -*- coding: utf-8 -*-# Python program to find H.C.F of two numbers# define a functiondef compute_hcf(x, y):# choose the smaller number   if x > y:       smaller = y   else:       smaller = x   for i in range(

Python Program to display the Fibonacci sequence up to n-th term

Filed under: Python on 2023-09-17 22:01:16
#!/usr/bin/python# -*- coding: utf-8 -*-# Program to display the Fibonacci sequence up to n-th termnterms = int(input('How many terms? '))# first two terms(n1, n2) = (0, 1)count = 0# check if the number of terms is validif nterms <= 0:   print 'Please enter a positive integer'elif nterm

Python program for Armstrong number

Filed under: Python on 2023-09-17 22:00:40
#!/usr/bin/python# -*- coding: utf-8 -*-# Python program to check if the number is an Armstrong number or not# take input from the usernum = int(input('Enter a number: '))# initialize sumsum = 0# find the sum of the cube of each digittemp = numwhile temp > 0:   digit = temp % 10  &

Python program to find the Factorial of any number

Filed under: Python on 2023-09-17 21:59:54
#!/usr/bin/python# -*- coding: utf-8 -*-# Python program to find the factorial of a number provided by the user.# change the value for a different result# To take input from the usernum = int(input('Enter a number: '))factorial = 1# check if the number is negative, positive or zeroif num < 0:&nbs

Python program to find the largest of three numbers

Filed under: Python on 2023-09-17 21:57:19
#!/usr/bin/python# -*- coding: utf-8 -*-# Python program to find the largest number among the three input numbers# change the values of num1, num2 and num3# for a different result# uncomment following lines to take three numbers from usernum1 = float(input('Enter first number: '))num2 = float(input(

Python program to find the roots of Quadratic equation

Filed under: Python on 2023-09-17 21:56:49
#!/usr/bin/python# -*- coding: utf-8 -*-# Solve the quadratic equation ax**2 + bx + c = 0# import complex math moduleimport cmatha = 1b = 5c = 6# calculate the discriminantd = b ** 2 - 4 * a * c# find two solutionssol1 = (-b - cmath.sqrt(d)) / (2 * a)sol2 = (-b + cmath.sqrt(d)) / (2 * a)print 'The s

Python Program to find the area of triangle

Filed under: Python on 2023-09-17 21:55:27
#!/usr/bin/python# -*- coding: utf-8 -*-# Python Program to find the area of triangle# Uncomment below to take inputs from the usera = float(input('Enter first side: '))b = float(input('Enter second side: '))c = float(input('Enter third side: '))# calculate the semi-perimeters = (a + b + c) / 2# cal

Python program to swap two variables

Filed under: Python on 2023-09-17 21:54:55
#!/usr/bin/python# -*- coding: utf-8 -*-# Python program to swap two variables# To take inputs from the userx = input('Enter value of x: ')y = input('Enter value of y: ')# create a temporary variable and swap the valuestemp = xx = yy = tempprint 'The value of x after swapping: {}'.format(x)print 'Th

program to explain static import for static Field in Java

Filed under: Java on 2023-09-17 15:41:32
// program to explain static import for static Field.import java.util.Scanner;import static java.lang.Math.PI;class StaticImport2{public static void main( String args[ ] ){ double r, a; Scanner sc = new Scanner( System.in );  System.out.print("Enter Radius : "); r = sc.nextD

Program to explain static import statement in Java

Filed under: Java on 2023-09-17 15:40:54
//  program to explain static import statement.import static java.lang.Math.*;//   import static java.lang.Math.sqrt;class StaticImport{public static void main( String args[ ] ){ double a = 3.0, b = 4.0; double c = sqrt( a*a + b*b ); System.out.println(" C = " + c );}} 

Import with * sign example in Java

Filed under: Java on 2023-09-17 15:40:07
//  import with * sign.import  java.util.*;class  ImportTest2{public static void main( String args[ ] ){ double r, a; Scanner sc = new Scanner( System.in );  System.out.print("Enter Radius : "); r = sc.nextDouble();  a = 3.14 * r * r;  Syst

Using class without import in Java

Filed under: Java on 2023-09-17 15:39:27
//  Using class without import.class  ImportTest{public static void main( String args[ ] ){ double  r, a; java.util.Scanner sc = new java.util.Scanner( System.in );  System.out.print("Enter Radius : "); r = sc.nextDouble();  a = 3.14 * r * r; &n

Using class with import example in Java

Filed under: Java on 2023-09-17 15:38:49
//  Using class with import.import java.util.Scanner;class ImportTest2{public static void main( String args[ ] ){ double r, a; Scanner sc = new Scanner( System.in );  System.out.print("Enter Radius : "); r = sc.nextDouble();  a = 3.14 * r * r;  Syste

Visibility control in another package example in Java

Filed under: Java on 2023-09-17 15:38:14
// Program to  Visibility Control in Another Package.// First File ( Base.java ) in package p1package  p1;public class  Base {private int n_pri = 1;int n_def = 2;protected int n_pro = 3;public int n_pub = 4;public Base() { System.out.println("base constructor"); Sy

Program to Visibility Control in Same Package example in Java

Filed under: Java on 2023-09-17 15:37:29
// Program to Visibility Control in Same Package.// First File ( Base.java ) in package p1package p1;public class Base {private int n_pri = 1;int n_def = 2;protected int n_pro = 3;public int n_pub = 4;public Base() { System.out.println("base constructor"); System.out.println("n_p

Program to explain Importing Package example in Java

Filed under: Java on 2023-09-17 15:36:40
//  Program to explain Importing Packagepackage MyPack;public class  Balance {String name;double bal;public Balance(String n, double b) { name = n; bal = b;}public void show() { if(bal<0)  System.out.print("--> "); System.out.println(name + ": 

Program to explain Creating Package in Java

Filed under: Java on 2023-09-17 15:36:05
//  Program to explain Creating Package.package MyPack;class  Balance {String name;double bal;Balance(String n, double b) { name = n; bal = b;}void show() { if(bal<0)  System.out.print("--> "); System.out.println(name + ": Rs. " + bal);}}class 

Program to explain Importing Package in Java

Filed under: Java on 2023-09-17 15:35:29
// Program to explain Importing Package.package  Pack1;public class  First{public void view( ){ System.out.println( "This is First Class." );}}// Second File as (ImportPack1.java in current folder) :import Pack1.*;public class  ImportPack1{public static void main( String args[ ] 

Creating package example in Java

Filed under: Java on 2023-09-17 13:20:18
// Program to explain Creating Package.package  Pack1;class First{public void view( ){ System.out.println( "This is First Class." );}}public class  ImportPack2{public static void main( String args[ ] ){ First f = new First(); f.view();}} Output:This is First Class.

Program to Implement a class from multiple interfaces in Java

Filed under: Java on 2023-09-17 13:18:41
// Program to Implement a class from multiple interfaces.interface  A{void showA();}interface  B {void showB();}class  C  implements  A, B{public void showA(){ System.out.println("showA() of A interface.");}public void showB(){ System.out.println("showB() of B

Polymorphism with interface example in Java

Filed under: Java on 2023-09-17 13:17:59
//  Polymorphism  with interface exampleinterface Shape{void draw();}class Rectangle implements Shape{public void draw(){ System.out.println("Drawing Rectangle.");}}class Triangle implements Shape{public void draw(){ System.out.println("Drawing Triangle.");}}class  Polymorph

Program to explain Inheritance of a interface in Java

Filed under: Java on 2023-09-17 13:16:47
//  Program to explain Inheritance of a interface//  from another interface.interface AInterface{void showA();}interface BInterface extends AInterface {void showB();}class Test  implements BInterface{public void showA(){ System.out.println("showA() of A interface.");}public 

Use fields in interface example in Java

Filed under: Java on 2023-09-17 13:15:33
//  Program to use field in interface.interface AInterface{int  SIZE = 100;void  showA();}class Test  implements  AInterface{public void showA(){ System.out.println("showA() of A interface."); System.out.println("SIZE = " + SIZE);}}class  InterfaceTest2{public

Simple interface example in Java

Filed under: Java on 2023-09-17 13:14:57
//  Program to use Simple Interface.interface  AInterface{void showA();}class Test  implements  AInterface{public void showA(){ System.out.println("showA() of A interface.");}}class  InterfaceTest1{public static void main( String args[ ] ){ Test  t1 = new Test

Program to explain final method restricts in Java

Filed under: Java on 2023-09-17 07:10:08
//  Program to explain final method restricts //  (not allow) the overriding of that methodclass  A{final void display(){ System.out.println(" A\'s display().");}}class  B extends A{// final method can't be override.// void display()void show(){ System.out.println(

Program to explain final class restricts (not allow) in Java

Filed under: Java on 2023-09-17 07:09:35
// Program to explain final class restricts (not allow) // the inheritance from that class.final class A{void display(){ System.out.println(" A\'s display().");}}// final class can't be inherited.// class B extends A // Errorclass B{void display(){ System.out.println(" B\'s display().

Program to explain Polymorphism with abstract class in Java

Filed under: Java on 2023-09-17 07:05:35
//  Program to explain Polymorphism with abstract class.abstract class Shape{abstract void draw();}class Rectangle extends Shape{void draw(){ System.out.println("Drawing Rectangle.");}}class Triangle extends Shape{void draw(){ System.out.println("Drawing Triangle.");}}class  Poly

Program to explain Polymorphism in Java

Filed under: Java on 2023-09-17 07:01:53
//  Program to explain Polymorphism or //  Dynamic Method Dispatch or Run Time Binding.class  Shape{void draw(){ System.out.println("Drawing Shape.");}}class  Rectangle extends Shape{void draw(){ System.out.println("Drawing Rectangle.");}}class  Triangle exten

Method overriding example in Java

Filed under: Java on 2023-09-17 07:00:43
// Program to explain Method Overriding.class  A {int  i,  j;A(int a, int b) { i = a; j = b;}void show() { System.out.println("i and j: " + i + " " + j);}}class  B extends A {int  k;B(int a, int b, int c) { super(a, b); k = c

Method Overloading example in Java

Filed under: Java on 2023-09-17 07:00:19
// Program to explain Method Overloading.class  A {int i, j;A(int a, int b) { i = a; j = b;}void show() { System.out.println("i and j: " + i + " " + j);}}class  B extends A {int k;B(int a, int b, int c) { super(a, b); k = c;}void show(Strin

Hierarchical inheritance example in Java

Filed under: Java on 2023-09-17 06:58:31
//  hierarchical inheritance exampleclass student1{   private String name;   private int rno;      void setname(String name, int rno)   {       this.name = name;       this.rno = rno;   }  &

Use of super keyword to call super class constructor in Java

Filed under: Java on 2023-09-17 06:57:43
// Program to use super keyword to call Super class constructor to // initialize super class instance variablesclass Box {private double width;private double height;private double depth;Box(Box ob) {  width = ob.width; height = ob.height; depth = ob.depth;}Box(doub

Use of this keyword example in Java

Filed under: Java on 2023-09-17 06:56:56
//  Program to use this keywordclass n {   public int i;   int getI() {       return i;   }}class M extends n {   int a, b;   void sum(int a, int b) {       int d = getI();       this.a

Multilevel inheritance example in Java

Filed under: Java on 2023-09-17 06:56:32
//  Program to explain Multilevel Inheritance.class Box {private double width;private double height;private double depth;Box(Box ob) {  width = ob.width; height = ob.height; depth = ob.depth;}Box(double w, double h, double d) { width = w; height = h;

Simple Inheritance Example 2 in Java

Filed under: Java on 2023-09-17 06:56:01
// Simple Inheritance example 2class  A {int i, j;void showij() { System.out.println("i and j: " + i + " " + j);}}class B extends A {int k;void showk() { System.out.println("k: " + k);}void sum() { System.out.println("i+j+k: " + (i+j+k));}}class  Inh

Simple Inheritance Example in Java

Filed under: Java on 2023-09-17 06:55:33
// Simple Inheritance examplepublic class SimpleInheritance{   public static void main(String[] args) {       SubClass ob1 = new SubClass();       ob1.showmsgSuper();       ob1.showmsgSub();   }}class SuperClass{  &

Array of String Example in Java

Filed under: Java on 2023-09-17 06:55:03
// Program to explain the concept of "ARRAY OF STRING".class  StrArray{public static void main( String args[ ] ){ final int days = 7; String str[ ] = { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"   };   for( int  j=0 ; j<day

stringBuffer reverse () method example in Java

Filed under: Java on 2023-09-17 06:54:31
// Program to explain the following StringBuffer function :// StringBuffer reverse()class  Mreverse{public static void main( String args[ ] ){ StringBuffer sb = new StringBuffer( "Java Programming Examples." ); System.out.println( " String = " + sb );  sb.reverse(); Sys

stringBuffer replace () method example in Java

Filed under: Java on 2023-09-17 06:53:46
// Program to explain the following StringBuffer function :// StringBuffer replace( int startIndex, int endIndex, String str )class  Mreplace1{public static void main( String args[ ] ){ StringBuffer sb = new StringBuffer( "Java Programming Examples." ); System.out.println( " String = 

stringBuffer insert(index, obj) function example in Java

Filed under: Java on 2023-09-17 06:53:13
// Program to explain the following StringBuffer function :// StringBuffer insert( int index, Object ob )class  Minsert1{public static void main(String args[ ]){ StringBuffer sb = new StringBuffer(40); sb = sb.insert(0, 'A'); System.out.println(" String 1 = " + sb);  sb

stringBuffer insert() method example in Java

Filed under: Java on 2023-09-17 06:52:17
// Program to explain the following StringBuffer function :// StringBuffer insert( int index, String str )class  Minsert{public static void main( String args[ ] ){ String s = new String( "Java" ); StringBuffer sb = new StringBuffer( " Examples." ); sb = sb.insert( 0, s ); Sy

stringBuffer deleteCharAt() method in Java

Filed under: Java on 2023-09-17 06:51:38
// Program to explain the following StringBuffer function :// StringBuffer deleteCharAt( int loc )class  MdeleteCharAt{public static void main( String args[ ] ){ StringBuffer sb = new StringBuffer( "Java Programming Examples." ); System.out.println( " String = " + sb );  sb 

stringBuffer delete function in Java

Filed under: Java on 2023-09-17 06:51:06
// Program to explain the following StringBuffer function ://StringBuffer delete( int startIndex, int endIndex )class  Mdelete{public static void main( String args[ ] ){ StringBuffer sb = new StringBuffer( "Java Programming Examples." ); System.out.println( " String = " + sb ); &

Use ViewResolver in Spring MVC

Filed under: Spring on 2023-08-27 17:24:38
view resolver is a class in spring framework which allows us to configure urls dynamically ctrl + shift + T to open type in eclipse, search *Viewresolver you will find InternalResourceViewResolver this class will do it automatically.Make a bean of this class in mainController-servlet.xml file (

Map your Controller with the jsp file (Views) in Spring MVC

Filed under: Spring on 2023-08-27 17:24:05
In previous spring topic, we were returning a string from our methods which were written in our controller.In this topic, we are going to see how to map url with the viewNote: all the views will be stores in WEB-INF folder. You can store anywhere but it is recommended that you store all the views in

toString() method in spring buffer in Java

Filed under: Java on 2023-08-23 18:58:36
// Program to explain the following StringBuffer function ://String toString()class  MtoString{public static void main( String args[ ] ){ StringBuffer sb = new StringBuffer( "Java Programming Examples." );  String s = sb.toString(); System.out.println( " String = " + s );&nb

subString() method example in stringBuffer in Java

Filed under: Java on 2023-08-23 18:57:52
// Program to explain the following StringBuffer function ://String substring( int startIndex )//String substring( int startIndex, int endIndex )class  Msubstring1{public static void main( String args[ ] ){ StringBuffer sb1 = new StringBuffer( "Java Programming Examples." );  Sys

setLength() method example in Java

Filed under: Java on 2023-08-23 18:57:03
// Program to explain the following StringBuffer function :// void setLength( int len )class  MsetLength{public static void main(String args[ ]){ StringBuffer sb1 = new StringBuffer("Java Programming Examples."); System.out.println(" String = " + sb1); sb1.setLength(12); Sys

Use of setCharAt() method in Java

Filed under: Java on 2023-08-23 18:56:33
// Program to explain the following StringBuffer function :// void setCharAt( int where, char ch )class  MsetCharAt1{public static void main( String args[ ] ){ StringBuffer sb1 = new StringBuffer( "Java Nrogramming Examples." ); System.out.println( " String Before Replacing = " + sb1 

capacity() method example in Java

Filed under: Java on 2023-08-23 18:56:04
// Program to explain the following StringBuffer function :// int capacity()class  Mcapacity{public static void main( String args[ ] ){ StringBuffer sb1 = new StringBuffer(); StringBuffer sb2 = new StringBuffer( "Java Programming Examples" ); System.out.println( " Capacity = " + 

stringBuffer append example in Java

Filed under: Java on 2023-08-23 18:55:29
// Program to explain the following StringBuffer function :// StringBuffer append( char c )class  Mappend1{public static void main( String args[ ] ){ StringBuffer sb = new StringBuffer( 40 ); sb = sb.append( 'J' ); System.out.println( " String 1 = " + sb );  sb.append( 

stringBuffer() example in Java

Filed under: Java on 2023-08-23 18:54:55
// Program to explain the following StringBuffer function :// StringBuffer()// StringBuffer( int size )// StringBuffer( String str )class  MStringBuffer1{public static void main(String args[ ]){ StringBuffer sb = new StringBuffer("Java");  System.out.println(" sb = " + sb ); 

lastIndexOf() method example in Java

Filed under: Java on 2023-08-23 18:54:29
// Program to explain the following String function :// int lastIndexOf( String str )class  MlastIndexOf{public static void main( String args[ ] ){ String s1 = "Java Programming Examples Java Programming Examples.";    System.out.println( " Last Index of " + 'P' + " = " + s1

index of() method example in Java

Filed under: Java on 2023-08-23 18:54:04
// Program to explain the following String function :// int indexOf(int ch) // int indexOf( String str )class  MindexOf{public static void main(String args[ ]){ String s1 = "Java Programming Examples Java Programming Examples.";    System.out.println(" Index of " + 'P' 

subString() method example in Java

Filed under: Java on 2023-08-23 18:53:38
// Program to explain the following String function :// String substring( int startIndex )// String substring( int startIndex, int endIndex )class  Msubstring{public static void main( String args[ ] ){ String s1 = "Java Programming Examples.";   String s2 = s1.substring( 5 )

valueOf() method example in Java

Filed under: Java on 2023-08-23 18:53:00
//  Program to explain the following String function ://  static String valueOf( double num )class  MvalueOf {public static void main( String args[ ] ){ char  ch[ ] = { 'J', 'A', 'V', 'A' }; String s1 = String.valueOf( ch ); System.out.println( " String 1 : " 

trim() method example in Java

Filed under: Java on 2023-08-23 18:52:29
// Program to explain the following String function :// String  trim()class  Mtrim{public static void main( String args[ ] ){ String s = "            Java Programming Examples.           ".trim(); System.out.print( "String af

toUpperCase() method example in Java

Filed under: Java on 2023-08-23 18:51:59
// Program to explain the following String function :// String toUpperCase()class  MtoUpperCase{public static void main( String args[ ] ){ String s1 = "Java Programming Examples"; String s2 = s1.toUpperCase(); System.out.println( " Original  String : " + s1 ); System.ou

toLowerCase() method example in Java

Filed under: Java on 2023-08-23 18:51:33
// Program to explain the following String function : // String toLowerCase()class  MtoLowerCase{public static void main( String args[ ] ){ String s1 = "Java Programming Examples."; String s2 = s1.toLowerCase(); System.out.println( " Original  String : " + s1 ); Sy

split() method example in Java

Filed under: Java on 2023-08-23 18:51:06
// Program to explain the following String function :// String[ ] split( Stirng regExp )class  Msplit{public static void main( String args[ ] ){ String s1 = new String( "Java Programming Examples" ); String s2[ ] = s1.split( " " ); System.out.println( " String = " + s2[0] ); 

regionMatches() method example in Java

Filed under: Java on 2023-08-23 18:50:39
// Program to explain the following String function :// boolean regionMatches( int startIndex,// String str2, int str2StartIndex, int numChars )class  MregionMatches1 {public static void main(String args[ ]){ boolean b,b1; String s1 = new String("Java Programming Examples.");&nbs

getChars() method example in Java

Filed under: Java on 2023-08-23 18:49:57
// Program to explain the following String function :// void getChars( int sourceStart, int sourceEnd,// char target[], int targetStart )class  MgetChars{public static void main( String args[ ] ){ char  ch[ ] = new char[4]; String s1 = "Java Programming Examples.";  &nb

compareTo() method example in Java

Filed under: Java on 2023-08-23 18:49:18
// Program to explain the following String function :// int compareTo( String str )class  McompareTo{public static void main( String args[ ] ){ String s1 = "JAVA"; String s2 = "JAVA"; String s3 = "Java";    System.out.println( s1 + " compared to " + s2 + " = " + s1

Difference between equals and == operator in Java

Filed under: Java on 2023-08-23 18:48:34
// Program to explain the following String function :// equals versus ==class  MequalsVersusEqualto{public static void main( String args[ ] ){ boolean b; String s1 = "JAVA"; String s2 = "JAVA"; String s3 = "Java"; String s4 = new String( "JAVA" ); String s5 = new S

equalsIgnoreCase() function example in Java

Filed under: Java on 2023-08-23 18:47:45
// Program to explain the following String function :// boolean equalsIgnoreCase( Object str )class  MequalsIgnoreCase{public static void main( String args[ ] ){ String s1 = "JAVA";  String s2 = "JAVA"; String s3 = "Java"; System.out.println( s1 + " equals " + s2 + " = 

length() function example in Java String

Filed under: Java on 2023-08-23 06:58:27
// Program to explain the following String function :// int length()class  Mlength{public static void main( String args[ ] ){ char ch[ ] = { 'J', 'A', 'V', 'A' }; String s1 = new String( ch ); System.out.println( " String = " + s1 ); System.out.println( " Length = " + s1.len

Java Program to use charAt function in string

Filed under: Java on 2023-08-23 06:57:40
// Program to explain the following String function :// char charAt( int where )class  McharAt{public static void main( String args[ ] ){ char ch; String s1 = "Nils";   ch = s1.charAt( 0 ); System.out.println( " Character at 0 : " + ch ); ch = "Java".charAt( 3

Make string using ASCII value in Java

Filed under: Java on 2023-08-23 06:57:05
// Program to explain the following String function :// String( byte asciiChars[ ] )class  MString4{public static void main( String args[ ] ){ char ch[ ] = { 'J', 'A', 'V', 'A' }; String s1 = new String( ch ); byte b[ ] = { 65, 66, 67, 68, 69, 70 }; String s2 = new String( b

Simple string function example in Java

Filed under: Java on 2023-08-23 06:56:05
// Program to explain the following String function :// String(char chars[ ], int startIndex, int numChars)class  MString2{public static void main( String args[ ] ){ char ch[ ] = { 'J', 'A', 'V', 'A' }; String s = new String( ch, 2, 2 ); System.out.println( " String = " + s );&nb

Simple string example in Java

Filed under: Java on 2023-08-23 06:55:35
// Program to explain the following String function :// String( String strObj )class  MString11{public static void main( String args[ ] ){ String s1 = "Nils : " + 5 + 5;  String s2 = "Nils : " + (5 + 5); System.out.println( s1 ); System.out.println( s2 );}}Output:Nils :

Initialise 2D array in Java

Filed under: Java on 2023-08-23 06:54:46
// Program to initialize 2D array with expressionclass  InitTwoDWithExp {public static void main(String args[ ]) { double a[ ][ ] = {   { 0*0, 1*0, 2*0, 3*0 },   { 0*1, 1*1, 2*1, 3*1 },   { 0*2, 1*2, 2*2, 3*2 },   { 0*3, 1*3, 2*3, 3*3 } };&

Jagged array example in Java

Filed under: Java on 2023-08-23 06:54:05
//  Program to explain Jagged Arrayclass  JaggedArray2 {public static void main(String args[ ]) { int ar[ ][ ] = new int[4][ ]; ar[0] = new int[1]; ar[1] = new int[2]; ar[2] = new int[3]; ar[3] = new int[4]; int  i, j, x = 1; for( i=0 ; i &

Jav Program to find sum of two matrices

Filed under: Java on 2023-08-23 06:53:38
// Program to addition of two Matrixclass  MatrixAddition{public static void main( String args[ ] ){ int  i, j; int  c[ ][ ] = new int[3][3];  int  a[ ][ ] = {      {1, 2, 3},     {4, 5, 6},     {7, 8, 9}  };&n

Transpose of the array in Java

Filed under: Java on 2023-08-23 06:51:24
//Program to find transpose of the Matrixclass  MatrixTranspose{public static void main( String args[ ] ){ int i, j; int  b[ ][ ] = new int[3][3];  int   a[ ][ ] = {      {1, 2, 3},    {4, 5, 6},      {7, 8, 9}  }; 

Matrix of array example in Java

Filed under: Java on 2023-08-23 06:50:50
// print simple matrix of arraypublic class PrintingInMatrixFormat{   public static void main(String[] args)   {       int i,j;       int a[][]=new int[3][3];       a[0][0]=10;       a[0][1]=20; 

Iterate 2D array in Java

Filed under: Java on 2023-08-23 06:49:05
// Program to use Two dimensional Arrayclass TwoDArray {public static void main(String args[ ]) { int a[ ][ ]= new int[2][3]; int i, j, x = 1; for(i=0; i<2; i++) {  for(j=0; j<3; j++)   {   a[ i ][ j ] = x;   x++;  } }&

Program for Sum of 2D array elements in Java

Filed under: Java on 2023-08-23 06:48:23
// Sum Of Array Elementspublic class SumOfArrayElements{   public static void main(String[] args) {       int i, j, sum = 0;       int a[][] = {{10, 20, 30}, {40, 50, 60}, {70, 80, 90}};       for (i = 0; i < 3; i++) {  &n

Merge sort example in Java

Filed under: Java on 2023-08-23 06:47:40
// Program to Implement Merge Sortimport java.util.Scanner;public class MergeSort {   /* Merge Sort function */   public static void sort(int[] a, int low, int high)    {       int N = high - low;           &nb

Quick sort example in Java

Filed under: Java on 2023-08-23 06:47:20
// Java Program to Implement Quick Sortimport java.util.Scanner; public class QuickSort {   /** Quick Sort function **/   public static void sort(int[] arr)   {       quickSort(arr, 0, arr.length - 1);   }   /** Quick so

Selection sort example in Java

Filed under: Java on 2023-08-23 06:46:58
// Program to SORT the Array elements using SELECTION SORTclass  SelectionSort{public static void main( String args[ ] ){ int  i, j; int  a[ ] = { 40, 20, 50, 10, 30 };  System.out.print( "\n Unorted Numbers are = " ); for( i=0 ; i<5 ; i++ ) {  Sy

Insertion sort example in Java

Filed under: Java on 2023-08-23 06:46:38
//  Program to SORT the Array elements using INSERTION SORTclass  InsertionSort{public static void main( String args[ ] ){ int  a[ ] = { 0, 20, 40, 10, 50, 30 }; int i, n = 5; System.out.print( " The Unsorted Array is = " ); for( i=1 ; i<=n ; i++ ) {  

Bubble sort example in java

Filed under: Java on 2023-08-23 06:46:12
// Program to SORT the Array elements using BUBBLE SORTclass  BubbleSort{public static void main( String args[ ] ){ int i, j, t; int  a[ ] = { 40, 20, 50, 10, 30 };  System.out.print( "\n Unorted Numbers  are = " ); for( i=0 ; i<5 ; i++ ) {  Syste

Fibonacci series using Array in Java

Filed under: Java on 2023-08-23 06:45:49
//  Program to Print the Fibonacci Series using Array.class  FiboArray{public static void main( String args[ ] ){ int n, i; int  a[ ] = new int[20];   n = 10; a[0] = 0;   a[1] = 1;   for(i=2 ; i<n ; i++)    {  a[

Array Example in C++

Filed under: C++ on 2023-08-20 14:11:47
#include<stdio.h>#include<conio.h>int main(){int i, arr[7]={1,2,3,4,5,6,7};for(i=0; i<10; i++){ printf("\n %d", arr[i]);}} 

All C++ Functions List Alphabatically

Filed under: C++ on 2023-08-20 14:09:09
##define#elif#else#endif#if#ifdef#ifndef#include#pragma pack#pragma#undef BBeginPaint()BitBlt()BOOLBUTTON CCreateCompatibleDC()CreateFontIndirect()CreateHatchBrush()CreatePatternBrush()CreatePen()CreateSolidBrush()CreateWindow() DDispatchMessage()DefWindowProc()DeleteObject()DrawText(

Program to arrange array in Ascending order in Java

Filed under: Java on 2023-08-19 18:39:56
// Arrange Array in Ascending orderpublic class ArrayAscending {   public static void main(String[] args) {       int i, temp, j;       int a[] = {1, 7, 5, 9, 2, 12, 53, 25};System.out.println("Before Ascending order:");for (i = 0; i < 8; i++) {&n

Read array from keyboard in Java

Filed under: Java on 2023-08-19 18:38:03
//  Read array from keyboardimport java.util.*;class  ArrayTest{public static void main( String args[ ] ){ Scanner sc = new Scanner( System.in ); int  i; int  a[ ] = new int[5];  for( i=0 ; i<5 ; i++ ) {  System.out.print( "Enter Value : " );

Simple static Array example in Java

Filed under: Java on 2023-08-19 18:36:19
// Simple static arraypublic class SimpleArray{   public static void main(String[] args)    {       int a[]={10,20,30,40,50};       for(int i=0;i<5;i++)       {           System.out.

How to Add Jar Files in Library of project in IntelliJ Idea

Filed under: Java on 2023-08-19 13:09:43
Hello Developers, If you stuck to find how to add jar files in library of your project in IntelliJ Idea follow below steps:Open your IntelliJ idea and open the project on which you are working.You will see a setting icon on top right corner of your screen. Click on that and select project struc

Do while Loop example in Java

Filed under: Java on 2023-08-18 07:00:44
// Do while exampleclass  DoWhileTest{public static void main( String args[ ] ){ int   i = 1; // 1.  Initialization do {  System.out.print( "  " + i );  i++; // 3.  Increment. }while ( i <= 5 ); // 2.  Test / Condition}}Output: 1 &n

Program to check Armstrong number in Java

Filed under: Java on 2023-08-18 07:00:21
An Armstrong number of three digits is an integer such that the sum of the cubes of its digits is equal to the number itself. For example, 371 is an Armstrong number since 3**3 + 7**3 + 1**3 = 371.Code// Program to check whether a given Number is// ArmStrong Number or not.class  ArmstrongTest{p

Program to find Strong number in Java

Filed under: Java on 2023-08-18 06:59:13
What is strong number?Strong number is a special number whose sum of the factorial of digits is equal to the original number. For Example: 145 is strong number. Since, 1! + 4! + 5!Code//Program to Check the given Number is STRONG Number or not.// Logic 145 = 1! + 4! + 5!  (i.e.,  145 = 1 +

Program to check palindrome number in Java

Filed under: Java on 2023-08-18 06:57:33
// check given number is palindrom or notpublic class PalindromeNumber {   public static void main(String[] args) {       int n = 1215;       int sum = 0;       int m = n;       while (n > 0) {    

Count number of digits in any given number in Java

Filed under: Java on 2023-08-18 06:55:39
// count number of given digitsclass  NumberOfDigits{public static void main( String args[ ] ){ int n, c;  n = 1234; c = 0; while( n != 0 ) {  n = n / 10;  c++; } System.out.println( " Number of Digits : " + c );}}Output:Number of Digits : 4

Nested while Loop example in Java

Filed under: Java on 2023-08-18 06:54:55
// Nested while loop examplepublic class NestedWhile{   public static void main(String[] args) {       int a = 1, b;       while (a <= 5) {           b = 1;           while (b <= a) {&

While Loop Example in Java

Filed under: Java on 2023-08-18 06:54:25
// simple while loop examplepublic class WhileLoop{   public static void main(String[] args) {       //learning       int a = 1;       while (a <= 5) {           System.out.println(" "+a);  &n

For each loop example 2 in Java

Filed under: Java on 2023-08-18 06:53:53
// for each loop exampleclass  ForEachTest {public static void main( String args[ ] ){  int  ar[ ] = { 10, 20, 30, 40, 50, 60, 70, 80, 90, 100 };   for(int  x : ar)    { System.out.print(x + " ");  x = x * 10;  // no effect on num

For each loop example in Java

Filed under: Java on 2023-08-18 06:53:12
// foreach examplepublic class ForEachLoop {   public static void main(String[] args) {       int arrayname[] = {1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21};//learn       for (int val : arrayname) {           System.out.print

Advance for loop example in Java

Filed under: Java on 2023-08-18 06:52:19
public class AdvancedForLoop {   public static void main(String[] args) {             String s1 = "INDIA";       char s2[] = new char[s1.length()];       for (int i = 0; i < s1.length(); i++) {    

Program to find HCF and LCM of two numbers in Java

Filed under: Java on 2023-08-18 06:51:38
 // Program to find HCF and LCM of Two given Number.import java.util.Scanner;class  HcfAndLcmExample{public static void main( String args[ ] ){ int a, b, i, s, hcf=0, lcm=0; Scanner sc = new Scanner( System.in );  System.out.print( " Enter First Number : " ); a = s

Program to check Prime Number using for loop in java

Filed under: Java on 2023-08-18 06:50:30
// Program to Check the Given Number is PRIME or NOT.class  PrimeTest{public static void main( String args[ ] ){ int i, n; boolean  flag = true;  n = 29;   for( i=2 ; i<=n/2 ; i++ ) {  if( n % i == 0 )  {   flag = false;   

Program to check whether given number is Perfect or not in Java

Filed under: Java on 2023-08-18 06:49:47
Before proceeding to our program code, we must see what is perfect number.What is perfect number?In number theory, a perfect number is a positive integer that is equal to the sum of its positive divisors, excluding the number itself. For instance, 6 has divisors 1, 2 and 3 (excluding itself), and 1 

Program to Print Lucas series in Java

Filed under: Java on 2023-08-18 06:46:47
// Program to Print the Lucas Series.//  1  1  1  3  5  9.....n  Terms.class  LucasTest {public static void main( String args[ ] ){ int n, i , a = 1, b = 1, c = 1, d;   n = 10; System.out.print( " " + a + " " + b + " " + c);  

Print Fibonacci numbers example using Java

Filed under: Java on 2023-08-18 06:46:16
//  Program to Calculate the Fibonacci Series of the Given Number.class  FibonacciTest {public static void main( String args[ ] ){ int n, i , a = 0, b = 1, c = 0;   n = 6; System.out.print( " " + a + " " + b );    for( i=1 ; i<=(n-2) ; i++ )&

Program for getting Factorial of any number in Java

Filed under: Java on 2023-08-18 06:45:28
//Program to Calculate the Factorial of the Given Number.class  FactorialTest{public static void main( String args[ ] ){ int i, n;  n = 5; int f = 1; for( i=n ; i>=1 ; i-- ) {  f = f * i ; } System.out.println( "\n The Factorial of " + n + " is = 

Continue statement example in Java

Filed under: Java on 2023-08-18 06:44:47
// continue staement examplepublic class ContinueStatement{   public static void main(String[] args) {       for (int i = 0; i < 10; i++) {                       if (i % 2 == 0) {        

Label block and break example in Java

Filed under: Java on 2023-08-18 06:44:16
//  Label block and breakpublic class BreakAsGoto{   public static void main(String[] args) {       aBlock:       {           bBlock:           {           

Break statement example in Java

Filed under: Java on 2023-08-18 06:43:35
// Break startment in for loop examplepublic class BreakStatement{   public static void main(String[] args) {       for (int i = 0; i < 10; i++) {           System.out.println(i);           if(i==5){  &

Square Pattern of star logic in Java

Filed under: Java on 2023-08-18 06:42:50
//pattern using for and whilepublic class ForPattern{   public static void main(String[] args) {       int i, j;       for (i = 1; i <= 5; i++) {           for (j = 1; j <= 5; j++) {        &nbs

Print star Patter 2 logic in Java

Filed under: Java on 2023-08-18 06:42:09
// for loop and while looppublic class ForWhile {   public static void main(String[] args) {       for (int i = 1; i <= 5; i++) {           int j = i;           while (j <= 5) {       

Print star patter 1 logic in Java

Filed under: Java on 2023-08-18 06:38:27
// For loop patternpublic class NestedFor {   public static void main(String[] args) {       for (int i = 0; i < 5; i++) {           for (int j = 0; j <= i; j++) {               System.out.print

Sum of Even and Odd using For Loop in Java

Filed under: Java on 2023-08-18 06:37:55
This program will print sum of Even numbers and odd numbers separately.// sum of even odd using while loopclass OddEvenSum {   public static void main(String[] args) {       int i;       int sum = 0;       int sum1 = 0;  &nbs

Get Sum of n numbers using For Loop in Java

Filed under: Java on 2023-08-18 06:36:56
This program will print the sum of n numbers. // sum of numbers using command lineclass  ArguSum{   public static void main( String args[ ] )   { int  s = 0, len; len = args.length;  for( int i=0 ; i<len ; i++ ) {  int  x = Int

Simple for loop example in Java

Filed under: Java on 2023-08-18 06:35:54
Here we have made a simple for loop example in Java.// Simple for loop examplepublic class ForLoop{   public static void main(String[] args) {       for (int i = 0; i < 5; i++) {           System.out.println("Loop : "+i);    &n

String Literal in case of Switch in Java

Filed under: Java on 2023-08-12 20:54:23
//  Program to use String literal in case of switch-case statementimport java.util.*;class  SwitchString{public static void main(String args[ ]){ String dname; Scanner sc = new Scanner( System.in );  System.out.print( " Enter Day Name = " ); dname = sc.next(); 

Type of byte using Switch case in Java

Filed under: Java on 2023-08-12 20:53:15
// Switch case examplepublic class SwitchCase{   public static void main(String[] args) {       int choice = 1;       switch (choice) {           case 0:               System.out.p

Find Odd Even using Switch statement in Java

Filed under: Java on 2023-08-12 20:52:05
// Even odd using switch caseclass  EvenOdd{public static void main(String args[ ]){ for( int i=1 ; i<=10 ; i++ ) {  switch( i )  {   case 1:   case 3:   case 5:   case 7:   case 9:    System.out.println( i + " -

Find Day by day number using switch statement in Java

Filed under: Java on 2023-08-12 20:51:13
// Find day using switch caseclass  SwitchCaseDays {public static void main(String args[ ]){ int day; day = 6; switch( day ) {  case 1:   System.out.println( " Monday." );   break;  case 2:   System.out.println( " Tuesday." );&nbs

Simple Switch case example in Java

Filed under: Java on 2023-08-12 20:50:25
// Simple switch case exampleclass SwitchDemo {public static void main( String args[ ] ){ int  a = 2;  switch (a)  {  case 1 :   System.out.println("One.");   break;  case 2 :   System.out.println("Two.");   break;&

Simple program to check day by day number using if elsein Java

Filed under: Java on 2023-08-12 20:48:24
// Program to show Day Name according to Day Number ( 1 - 7 ) using else-if ladder statement.class  ElseIfDays{public static void main(String args[ ]){ int day; day = 7; if( day == 1 )  System.out.println( " Monday." ); else if( day == 2 )  System.out.println( " Tu

Program to find leap year in Java

Filed under: Java on 2023-08-12 20:46:26
// Program to find given year is leap year or notclass  Leap2{public static void main( String args[ ] ){ int y; y = 2016; if( y % 100 == 0 ) {  if( y % 400 == 0 )   System.out.println( " It is a LEAP Year." );  else   System.out.println( " It is

Nested if-else example in Java

Filed under: Java on 2023-08-12 20:44:38
// Program to find Maximum of Three numbers using Nested-If.class Max3IfElse{public static void main( String args[] ){ int a, b, c, max; a = 23; b = 93; c = 10; if( a > b ) {  if( a > c )   max = a;  else   max = c;     

Nested if example in Java

Filed under: Java on 2023-08-12 20:43:55
//  Nested if examplepublic class NestedIf{  public static void main(String[] args) {  int a = 10;    if(a>0){      if(a<=10){          System.out.println("a --> 0 to 10");      }      &

Program to find Odd Even in Java

Filed under: Java on 2023-08-12 20:42:38
// Simple if else to find even odd numberclass EvenOddTest{public static void main( String args[] ){ int n; n = 23; if( n % 2 == 0 )  System.out.println("Number " + n + " is Even Number." ); else  System.out.println("Number " + n + " is Odd Number." );}}Output:Number 23

Program to Find maximum number in Java

Filed under: Java on 2023-08-12 20:42:01
// Simple if else examplepublic class IfElse{   public static void main(String[] args)    {      int a = 23, b = 47, c;        if(a>b)      {          System.out.println("a is greater than b")

If else example in Java

Filed under: Java on 2023-08-12 20:41:06
//  Simple if else exampleclass IfElse{public static void main( String args[ ] ){ int  n;  n = 23; if( n > 100 ) {  System.out.println( " The number is greater than 100." ); }  else {  System.out.println( " The number is smaller tha

Simple If statement example in Java 2

Filed under: Java on 2023-08-12 20:40:31
// Simple if examplepublic class SimpleIf{   public static void main(String[] args) {       int a = 10;       int b = 20;              if(a>b){           System.out.println("a i

Simple If statement example in Java

Filed under: Java on 2023-08-12 20:39:45
// Simple if exampleclass  SimpleIf{public static void main(String args[ ] ){ int  n;  n = 230; if( n > 100 ) {  System.out.println( " The number is greater than 100." ); }}}Output:The number is greater than 100.

Program to explain Implicit in Java

Filed under: Java on 2023-08-11 19:33:38
// Program to explain Implicit Conversion ( Automatic Type Conversion )class ImplicitConversion{public static void main( String args[ ] ){ Int  i = 2; float  f = 12.33f; byte  b = 1;  double d = 124.097; double  res = ( i - b ) * ( d / f );  &nb

Type Casting Example in Java

Filed under: Java on 2023-08-11 19:32:57
//  Program to explain Type Casting ( Explicit Conversion )class TypeCasting{public static void main( String args[ ] ){ int a; float b = 123.333f; System.out.println( " Before Casting = " + b ); a = (int) b;  System.out.println( " After Casting  = " + a );}}Ou

Program to use Short-Hand Assignment Operators in Java

Filed under: Java on 2023-08-11 19:32:24
//  Program to use Short-Hand Assignment Operators ( +=, -=, *=, /=, %= )class ShortHandAssign {public static void main(String args[ ]) { int a = 1; int b = 2; int c = 3; a += 5; b *= 4; c += a * b; c %= 6; System.out.println("a = " + a); S

Conditional Operators Examples 2 in Java

Filed under: Java on 2023-08-11 19:28:21
// Program to find the Largest of three given numbers using Conditional Operatorclass MaxOf3ConditionalOperator{public static void main( String args[ ] ){ int a, b, c, max = 0; a = 20; b = 30; c = 45;    max = ((a>b) ? ((a>c) ? a : c ) : ((b>c) ? b : c )); 

Conditional Operators Examples in Java

Filed under: Java on 2023-08-11 19:27:39
//Program to explain the concept of Conditional Operator in different styleclass ConditionalOperator{public static void main( String args[ ] ){       int a, b, max; a = 25; b = 14; max = ( ( a > b ) ? a : b ); System.out.print("\nMaximum Value is= " + max )

Boolean Logical Operator Example in Java

Filed under: Java on 2023-08-11 19:26:51
//  Program to use Boolean Logical Operators ( &, |, ^, !  )class  BoolLogic {public static void main(String args[ ]) { boolean a = true; boolean b = false;  boolean c = a | b; boolean d = a & b; boolean e = a ^ b; boolean f = !a;&n

Modulus Operator example in Java

Filed under: Java on 2023-08-11 19:26:14
// Program to use Modulus  operator ( % )class Modulus {public static void main(String args[ ]) { int x = 42; double y = 42.25; System.out.println("x mod 10 = " + x % 10); System.out.println("y mod 10 = " + y % 10);}}Output:x mod 10 = 2 y mod 10 = 2.25

Decrement Operator example in Java

Filed under: Java on 2023-08-11 19:25:39
// Decrement Operator Exampleclass DecrementOperatorExample{public static void main( String args[ ] ){ int a = 10, b = 20 ,c;  c = ( --a ) + ( --b ); //c = ( a-- ) + ( b-- );  System.out.println( " Value of a = " + a ); System.out.println( " Value of b = " + b );&n

Increment Operator Example in Java

Filed under: Java on 2023-08-11 19:25:04
// Increment Operator exampleclass  IncrementOperatoeExample{public static void main( String args[ ] ){ int a = 10, b = 20 ,c;  c = ( ++a ) + ( ++b );  // a++ is Post fix increment // ++b is pre fix increment  System.out.println( " Value of a = " + a );&n