Articles on Trending Technologies

Technical articles with clear explanations and examples

Format integer values with java.text.DecimalFormat

karthikeya Boyini
karthikeya Boyini
Updated on 11-Mar-2026 184 Views

Here, we are using the DecimalFormat class in Java to format integer value, which is the java.text.DecimalFormat package.Let us take the following format: DecimalFormat("0.######E0") and use the format() method for this purpose −new DecimalFormat("0.#####E0").format(5089) new DecimalFormat("0.#####E0").format(608)Since, we have used DecimalFormat class in Java, therefore importing the following package in a must −import java.text.DecimalFormat;The following is an example −Exampleimport java.text.DecimalFormat; public class Demo { public static void main(String[] argv) throws Exception { System.out.println(new DecimalFormat("0.#####E0").format(387979)); System.out.println(new DecimalFormat("0.#####E0").format(29797)); System.out.println(new DecimalFormat("0.#####E0").format(49788)); ...

Read More

SimpleDateFormat(“hh:mm:ss a”) in Java

karthikeya Boyini
karthikeya Boyini
Updated on 11-Mar-2026 4K+ Views

The following format displays time from −hh:mm:ssThe following format displays time with AM/ PM marker −hh:mm:ss aHere, we are using the SimpleDateFormat class to display date and time. Let us set it for the format we want i.e time and AM/PM Marker −Format f = new SimpleDateFormat("hh:mm:ss a"); String strResult = f.format(new Date()); System.out.println("Time = "+strResult);The following is an example −Exampleimport java.text.Format; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Calendar; public class Demo { public static void main(String[] args) throws Exception { // displaying current date and time ...

Read More

Format a message with date in Java

Krantik Chavan
Krantik Chavan
Updated on 11-Mar-2026 799 Views

To format the message with date in Java, we use the MessageFormat class and the Date class. The MessageFormat class gives us a way to produce concatenated messages which are not dependent on the language. The MessageFormat class extends the Serializable and Cloneable interfaces.Declaration - The java.text.MessageFormat class is declared as follows −public class MessageFormat extends FormatThe  MessageFormat.format(pattern, params) method formats the message and fills in the missing parts using the objects in the params array matching up the argument numbers and the array indices.The format method has two arguments, a pattern and an array of arguments. The pattern contains placeholder ...

Read More

Implicit conversion from UInt64 to Decimal in C#

Samual Sam
Samual Sam
Updated on 11-Mar-2026 468 Views

The ulong type represents a 64-bit unsigned integer i.e. UInt64.To implicitly convert a 64-bit unsigned integer to a Decimal, firstly set UInt64 value.ulong val = ulong.MaxValue;To convert ulong to decimal, assign the value.decimal dec; dec = val;Let us see the above example.Exampleusing System; public class Demo {    public static void Main() {       ulong val = ulong.MaxValue;       decimal dec;       Console.WriteLine("Implicit conversion from Ulong to Decimal");       dec = val;       Console.WriteLine("Decimal : "+dec);    } }OutputImplicit conversion from Ulong to Decimal Decimal : 18446744073709551615

Read More

time_nanosleep() function in PHP

George John
George John
Updated on 11-Mar-2026 111 Views

The time_nanosleep() function delays execution of the current script for few seconds and nanoseconds.Syntaxtime_nanosleep(sec, nsec)Parameterssec − The number of seconds to delay the script.nsec − The number of nanoseconds to delay the script.ReturnThe time_nanosleep() function returns true on success.ExampleOutputThe following is the output.02:57:04 02:57:06 02:57:08

Read More

Display numbers with leading zeroes in Java

Samual Sam
Samual Sam
Updated on 11-Mar-2026 3K+ Views

To display numbers with leading zeros in Java, useDecimalFormat("000000000000").Let us first set the format with DecimalFormat class −DecimalFormat decFormat = new DecimalFormat("000000000000");Now, let us display some numbers with leading zeros −String res = decFormat.format(298989); System.out.println(res); res = decFormat.format(565); System.out.println(res);The following is an example −Exampleimport java.text.DecimalFormat; public class Demo { public static void main(String args[]) { DecimalFormat decFormat = new DecimalFormat("000000000000"); String res = decFormat.format(298989); System.out.println(res); res = decFormat.format(565); ...

Read More

SimpleDateFormat(“HH.mm.ss”) in Java

Samual Sam
Samual Sam
Updated on 11-Mar-2026 12K+ Views

The format SimpleDateFormat(“HH.mm.ss”) displays time. To work with SimpleDateFormat class, we have imported the following package.import java.text.SimpleDateFormat;Here, we are using the SimpleDateFormat class to display date and time. Let us set it for the format we want i.e time - HH.mm.ss −Format f = new SimpleDateFormat("HH.mm.ss"); String strResult = f.format(new Date()); System.out.println("Time = "+strResult);The following is an example −Exampleimport java.text.Format; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Calendar; public class Demo { public static void main(String[] args) throws Exception { // displaying current date and time Calendar ...

Read More

LinkedList AddAfter method in C#

Chandu yadav
Chandu yadav
Updated on 11-Mar-2026 1K+ Views

Set a LinkedList.int [] num = {1, 2, 3, 4, 5}; LinkedList list = new LinkedList(num);Now add a node at the end using AddLast() method.var newNode = list.AddLast(20);To add a node after the above added node, use the AddAfter() method.list.AddAfter(newNode, 30);Exampleusing System; using System.Collections.Generic; class Demo {    static void Main() {       int [] num = {1, 2, 3, 4, 5};       LinkedList list = new LinkedList(num);       foreach (var n in list) {          Console.WriteLine(n);       }       // adding a node at the end ...

Read More

How to Initialize and Compare Strings in C#?

karthikeya Boyini
karthikeya Boyini
Updated on 11-Mar-2026 291 Views

To initializes a string in C# is an easy task. Let’s say you want to set a name “Amit”, for that, initialize your string as.String str1 = "Hello, World!";To compare strings, use the the following C# method.public static int Compare(string str1, string str2)To compare, if −String.Compare(str1, str2) == 0If the above is equal to 0, then both the strings are equal.The above method compares two specified string objects and returns an integer that indicates their relative position in the sort order.The following is an example that shows the comparison of one string to another.Exampleusing System; namespace Demo {    class ...

Read More

C++ Program to Print Number Entered by User

karthikeya Boyini
karthikeya Boyini
Updated on 11-Mar-2026 5K+ Views

The objects “cin” and “cout” are used in C++ for input and output respectively. cin is an instance of the istream class and is attached to the standard input device such as the keyboard. cout is an instance of the ostream class and is connected to the standard output device such as the display screen.A program that prints the number entered by the user is as follows −Example#include using namespace std; int main() {    int num;    coutnum;    cout

Read More
Showing 9271–9280 of 61,248 articles
« Prev 1 926 927 928 929 930 6125 Next »
Advertisements