Java Program to open the Command Prompt and Insert commands

Saba Hilal
Updated on 24-Jun-2024 15:53:26

5K+ Views

This article uses various approaches for selecting the commands inserted in the opened command window through the Java code. The command window is opened by using ‘cmd’. Here, the methods of doing the same are specified using Java code. The Command window is first opened using the Java program. It is opened as a child process. If the java program is run in an existing cmd window, another one is opened as a new process. Further, different types of commands are inserted and executed in that opened command window via the java code. These programs may not work in ... Read More

Java program to find the circumference of a circle

Ankith Reddy
Updated on 24-Jun-2024 15:46:10

6K+ Views

The circumference of a circle is double the product of its radius and the value of PI. Therefore, to calculate the circumference of a circleGet the radius of the circle form the user.Calculate the productPrint the final result.Example: Finding the circumference of a circle import java.util.Scanner; public class CircumfrenceOfCircle {    public static void main(String args[]){       int radius;       double circumference;       Scanner sc = new Scanner(System.in);       System.out.println("Enter the radius of the circle ::");       radius = sc.nextInt();       circumference = Math.PI*2*radius;       System.out.println("Circumference ... Read More

Java program to find the Frequency of a character in a given String

karthikeya Boyini
Updated on 24-Jun-2024 15:42:49

5K+ Views

To find the Frequency of a character in a given String Read a string from the user. Read the character. Create an integer variable initialize it with 0. Compare each character in the given string with the entered character increment the above created integer variable each time a match occurs.Exampleimport java.util.Scanner; public class FrequencyOfACharacter {    public static void main(String args[]){       System.out.println("Enter a string value ::");       Scanner sc = new Scanner(System.in);       String str = sc.nextLine();       System.out.println("Enter a particular character ::");       char character = sc.nextLine().charAt(0);       int count = 0;       for (int i=0; i

JavaScript function in href vs. onClick

Amit Sharma
Updated on 24-Jun-2024 15:36:43

10K+ Views

Both onclick & href have different behaviors when calling JavaScript directly. Also the script in href won’t get executed if the time difference is short. This is for the time between two clicks.ExampleHere’s an example showing the usage of href vs onClick in JavaScript. Live Demo           JavaScript href vs onClick()              function myFunc() {          var v = 0;          for (var j=0; j

Java Program to Get First or Last Elements from HashSet

Shiva Keerthi
Updated on 24-Jun-2024 15:06:22

2K+ Views

In Java, HashSet is a class which implements Set Interface. HashSet is a collection of unique elements which doesn’t store or allow us to store duplicate elements. In this section, we will be discussing about different approaches in java to find the first element and last element of a HashSet using Java programming Language. The HashSet class in java is implemented using a hash table. It uses hash code to retrieve data quickly from the table in HashSet, the order of elements is not preserved i.e., it doesn’t store the elements in the order in which we add elements ... Read More

What is the full form of Java?

Priya Mishra
Updated on 22-Jun-2024 19:36:03

831 Views

What is the Full Form of JAVA? The full form of Java is "Just Another Virtual Accelerator". Java is not an abbreviation but some programmers made a full form. Basically, Java doesn’t have any full form or special meaning. This full form is used jokingly by the programmers. J Just A Another V Virtual A Accelerator Related Links Some of the related topics, you may like to read: Overview of Java programming language Features of Java programming language

Explain putc() and getc() functions of files in C language

Bhanu Priya
Updated on 22-Jun-2024 17:42:24

10K+ Views

A file represents a sequence of bytes, regardless of it being a text file or a binary file. File is collection of records or is a place on hard disk, where data is stored permanently. Operations on files The operations on files in C programming language are as follows − Naming the file Opening the file Reading from the file Writing into the file Closing the file Syntax The syntax for opening a file is as follows − FILE *File pointer; For example, FILE * fptr; The ... Read More

Explain the functions putw() and getw() in C language

Bhanu Priya
Updated on 21-Jun-2024 23:45:30

10K+ Views

File is collection of records or is a place on hard disk, where data is stored permanently. Operations on files The operations on files in C programming language are as follows − Naming the file Opening the file Reading from the file Writing into the file Closing the file Syntax The syntax for opening a file is as follows − FILE *File pointer; For example, FILE * fptr; The syntax for naming a file is as follows − File pointer = fopen ("File name", "mode"); For example, fptr ... Read More

Explain fgetc() and fputc() functions in C language

Bhanu Priya
Updated on 21-Jun-2024 22:00:27

3K+ Views

File is collection of records or is a place on hard disk, where data is stored permanently.Operations on filesThe operations on files in C programming language are as follows −Naming the fileOpening the fileReading from the fileWriting into the fileClosing the fileSyntaxThe syntax for opening a file is as follows −FILE *File pointer;For example, FILE * fptr;The syntax for naming a file is as follows −File pointer = fopen ("File name", "mode");For example, fptr = fopen ("sample.txt", "r"); FILE *fp; fp = fopen ("sample.txt", "w");fgets( ) and fputs( ) functions fgets() is used for reading a string from a file.The ... Read More

Explain the conversions of expressions of stacks in C language

Bhanu Priya
Updated on 21-Jun-2024 21:50:10

1K+ Views

Stack is a linear data structure, where data is inserted and removed only at one end.AlgorithmsGiven below is an algorithm for Push ( ) −Check for stack overflow.if (top = = n-1) printf("stack over flow");Otherwise, insert an element into the stack.top ++ a[top] = itemGiven below is an algorithm for Pop ( ) −Check for stack underflow.if (top = = -1) printf("stack under flow");Otherwise, delete an element from the stack.item = a[top] top --Given below is an algorithm for Display ( ) −if (top == -1) printf ("stack is empty");Otherwise, follow the below mentioned algorithm.for (i=0; i

Advertisements