karthikeya Boyini

karthikeya Boyini

1,421 Articles Published

Articles by karthikeya Boyini

Page 28 of 143

Display path separator in Java

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

To display the path separator, use the Properties class and import the following package −import java.util.Properties;Use the getProperties() method first and create an object −Properties p = System.getProperties();Now, set the key for path separator −p.getProperty("path.separator")The following is an example −Exampleimport java.util.Properties; public class Demo { public static void main(String[] args) { Properties p = System.getProperties(); System.out.println("Separator is "+p.getProperty("path.separator")); } }OutputSeparator is :

Read More

Set width and precision to format output in Java

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

Set width in output as shown below. Here, %10 sets a 10 character fieldSystem.out.printf("d1 = %10.2f d2 = %8g", d1, d2);Above, the value after the decimal is for decimal places i.e. 5.3 is for 3 decimal places −System.out.printf("d1 = %5.3f d2 = %2.5f", d1, d2);The following is an example −Examplepublic class Demo { public static void main(String[] args) throws Exception { double d1 = 399.8877; double d2 = 298.87690; System.out.printf("d1 = %10.2f d2 = %8g", d1, d2); System.out.printf("d1 = %5.3f d2 = %2.5f", d1, d2); } }Outputd1 = 399.89 d2 = 298.877 d1 = 399.888 d2 = 298.87690

Read More

Concatenate null to a string in Java

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

To concatenate null to a string, use the + operator.Let’s say the following is our string.String str = "Demo Text";We will now see how to effortlessly concatenate null to string.String strNULL = str + "null";The following is the final example.Examplepublic class Demo {     public static void main(String[] args) {        String str = "Demo Text";        System.out.println("String = "+str);        String strNULL = str + "null";        System.out.println("String concatenated with NULL: "+strNULL);     } }OutputString = Demo Text String concatenated with NULL: Demo Textnull

Read More

C++ Program to Find the Number of Vowels, Consonants, Digits and White Spaces in a String

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

A string is a one dimensional character array that is terminated by a null character. There can be many vowels, consonants, digits and white spaces in a string.For example.String: There are 7 colours in the rainbow Vowels: 12 Consonants: 15 Digits: 1 White spaces: 6A program to find the number of vowels, consonants, digits and white spaces in a string is given as follows.Example#include using namespace std; int main() {    char str[] = {"Abracadabra 123"};    int vowels, consonants, digits, spaces;    vowels = consonants = digits = spaces = 0;    for(int i = 0; str[i]!='\0'; ++i) ...

Read More

Get localized short day-in-week name in Java

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

Use the ‘a’ date conversion character to display short day-in-week.System.out.printf("Localized short day name = %ta/%Ta", d, d);Above, d is a date object −Date d = new Date();The following is an example −Exampleimport java.util.Date; import java.text.DateFormat; import java.text.SimpleDateFormat; public class Demo { public static void main(String[] args) throws Exception { Date d = new Date(); DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss a"); String format = dateFormat.format(d); System.out.println("Current date and time = " + format); ...

Read More

C# Console BufferWidth Property

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

Use the BufferWidth gets or sets the width of the buffer area.Use the property like this −Console.BufferWidthLet us see the complete example.Exampleusing System; class Demo {    static void Main() {       Console.WriteLine("Buffer width (columns) = "+Console.BufferWidth);    } }OutputBuffer width (columns) = 0

Read More

Parse and format to hexadecimal in Java

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

To parse and format to hexadecimal in Java, we have used the BigInteger class. The java.math.BigInteger class provides operations analogues to all of Java's primitive integer operators and for all relevant methods from java.lang.Math.In the below example, we have taken BigInteger and created an object. With that, some values have been set by us in the arguments as the hexadecimal and the radix i.e. 16 for hexadecimal.BigInteger bi = new BigInteger("2ef", 16);Let us see an example.Exampleimport java.math.*; public class Demo {    public static void main( String args[] ) {       BigInteger bi = new BigInteger("2ef", 16);   ...

Read More

Different ways to format long with Java System.out.format

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

The System.out.format is used in Java to format output. Here, let’s say the following is our long. long val = 787890; To format, we have considered the following that justifies the output. System.out.format("%d%n", val); System.out.format("%9d%n", val); System.out.format("%+9d%n", val); System.out.format("%08d%n", val); System.out.format("%, 9d%n", val); The following is the complete example that displays the difference in output as well. Example import java.util.Locale; public class Demo { public static void main(String []args) { long val = 787890; System.out.format("%d%n", val); ...

Read More

Java Program to return a Date set to the last possible millisecond of the month before midnight

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

Use the getMaximum() method in Java to returns the maximum value for the given calendar field. We will use it to set the minute, second and millisecond.Let us first declare a calendar object −Calendar dateNoon = Calendar.getInstance();Now, we will set the hour, minute, second and millisecond to the last possible millisecond on the month before midnight.// hour, minute and second calendar.set(Calendar.HOUR_OF_DAY, calendar.getMaximum(Calendar.HOUR_OF_DAY)); calendar.set(Calendar.MINUTE, calendar.getMaximum(Calendar.MINUTE)); calendar.set(Calendar.SECOND, calendar.getMaximum(Calendar.SECOND)); // millisecond calendar.set(Calendar.MILLISECOND, calendar.getMaximum(Calendar.MILLISECOND));Now, do the following for month and day of month −calendar.set(Calendar.DAY_OF_MONTH, 1); // first day of month calendar.add(Calendar.MONTH, 1); calendar.add(Calendar.DAY_OF_MONTH, -1);The following is an example to return a Date set to ...

Read More

JSON. stringify( ) function in JavaScript

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

The stringify() function of a JSON object accepts a JSON string, and constructs an object based on the given text and, returns it.SyntaxIts Syntax is as followsJson.stringify();Example    JavaScript Example           var jsonSample = '{Tutorial: Java, Version:8}';       jsonObj = JSON.stringify(jsonSample);       document.write(jsonObj);     Output"{Tutorial: Java, Version:8}"

Read More
Showing 271–280 of 1,421 articles
« Prev 1 26 27 28 29 30 143 Next »
Advertisements