Java Program To Generate Random Number
01. Example: import java.util.*; class generateRandomNumbers { public static void main(String[] args) { int c; Random r = new Random(); for (c = 1; c <= 4; c++) { System.out.println(r.nextInt(100)); …
01. Example: import java.util.*; class generateRandomNumbers { public static void main(String[] args) { int c; Random r = new Random(); for (c = 1; c <= 4; c++) { System.out.println(r.nextInt(100)); …
Linear search is a simple search algorithm that involves examining each element of a list or array sequentially until the desired element is found or it is determined that the …
01. Example: import java.util.Scanner; class linearSearch { public static void main(String args[]) { int c, n, search, array[]; Scanner in = new Scanner(System.in); System.out.print("Enter Number Of Elements In Array: "); …
01. Example: import java.util.*; import java.io.*; class openNotepad { public static void main(String[] args) { Runtime cmd = Runtime.getRuntime(); try { cmd.exec("notepad"); } catch (IOException e) { System.out.println(e); } } …
01. Example: import java.net.InetAddress; class getIPAddress { public static void main(String args[]) throws Exception { System.out.println("You IP Address: " + InetAddress.getLocalHost()); } } Output: You IP Address: 50ebdf8d6ef6/172.17.0.8
01. Example: import java.util.*; class runGarbageCollection { public static void main(String s[]) throws Exception { Runtime data = Runtime.getRuntime(); System.out.println("Free Memory In JVM Before Garbage Collection = "+ data.freeMemory()); data.gc(); …
01. Example: import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; public class simpleDateFormat { public static void main(String[] args) { Date date = new Date(); System.out.println("**Date Format Change**"); SimpleDateFormat formatter …
01. Example: import java.sql.Date; public class stringToSQLDate { public static void main(String[] args) { String data = "2022-12-25"; Date date = Date.valueOf(data); System.out.println(date); } } Output: 2022-12-25
01. Example: public class fetchDateSQL { public static void main(String[] args) { long millis = System.currentTimeMillis(); java.sql.Date date = new java.sql.Date(millis); System.out.println("Today Date: "+date); } } Output: Today Date: 2022-12-24 …
Python abs() function: Returns absolute value. Converts negative number to positive number. Table Of Contents 01. Abs() Function Syntax 02. Abs() with Negative Number 03. Abs() with …