Programming Articles

Page 793 of 2544

C# Console.WindowWidth Property

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

The WindowWidth property gets or sets the width of the console window.Declare a variable.int width;Now, get the width of the current window.width = Console.WindowWidth;The following is the complete example.Exampleusing System; using System.Numerics; using System.Globalization; class Demo {    static void Main() {       int width;       int height;       width = Console.WindowWidth;       height = Console.WindowHeight;       Console.WriteLine("Current window width = "+width);       Console.WriteLine("Current window height = "+height);    } }OutputCurrent window width = 0 Current window height = 0

Read More

Determining If an Object Is an Array in Java

Anvi Jain
Anvi Jain
Updated on 11-Mar-2026 6K+ Views

In order to determine if an object is an Object is an array in Java, we use the isArray() and getClass() methods.The isArray() method checks whether the passed argument is an array. It returns a boolean value, either true or falseSyntax - The isArray() method has the following syntax -Array.isArray(obj)The getClass() method method returns the runtime class of an object. The getClass() method is a part of the java.lang.Object class.Declaration − The java.lang.Object.getClass() method is declared as follows −public final Class getClass()The getClass() method acts as the intermediate method which returns an runtime class of the object, which enables the terminal ...

Read More

Convert.ChangeType Method in C#

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

The ChangeType() method returns an object of the specified type and whose value is equivalent to the specified object.Let’s say we have a double type.double val = -3.456Now, use the ChangeType method to change the type to integer.num = (int)Convert.ChangeType(val, TypeCode.Int32);Let us see the complete example.Exampleusing System; public class Demo {    public static void Main() {       double val = -3.456;       int num = (int)Convert.ChangeType(val, TypeCode.Int32);       Console.WriteLine("{0} converted to an Int32: {1}", val, num);    } }Output-3.456 converted to an Int32: -3

Read More

Java Program to replace one specific character with another

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

Use the replace() method to replace a specific character with another. Let’s say the following is our string and here we are replacing a whitespace with a $ character.String str1 = "Orange is the new Black!";Now, use the replace() method to replace a character with $str1.replace(' ', '$');Examplepublic class Demo {    public static void main(String[] args) {       String str1 = "Orange is the new Black!";       System.out.println("String: "+str1);       String str2 = str1.replace(' ', '$');       System.out.println("Updated string: "+str2);    } }OutputString: Orange is the new Black! Updated string: Orange$is$the$new$Black!

Read More

Java Program to format date with System.out.format

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

System.out.format is used in Java to format output.Firstly, create a Calendar object −Calendar calendar = Calendar.getInstance();Now, use theDate-Time conversion characters to get the date, month and year −System.out.format("%te %tB, %tY%n", calendar, calendar, calendar);The following is the complete example −Exampleimport java.util.Locale; import java.util.Calendar; public class TestFormat {    public static void main(String[] args) {       Calendar calendar = Calendar.getInstance();       System.out.format("%te %tB, %tY%n", calendar, calendar, calendar);    } }Output22 November, 2018

Read More

Convert.ToBoolean Method in C#

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

The Convert.ToBoolean method is used to convert a specified value to an equivalent Boolean value.The following is our double type.double doubleNum = 329.34;To convert it to Boolean, use the Convert.ToBoolean() method.bool boolNum; boolNum = System.Convert.ToBoolean(doubleNum);Let us see another example.Exampleusing System; public class Demo {    public static void Main() {       double doubleNum = 3.4;       bool boolNum;       // Double to bool       boolNum = System.Convert.ToBoolean(doubleNum);       System.Console.WriteLine("{0} as a Boolean = {1}.", doubleNum, boolNum);    } }Output3.4 as a Boolean = True.

Read More

Set Date patterns with SimpleDateFormat in Java

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

The following pattern letters are defined (all other characters from 'A' to 'Z' and from 'a' to 'z' are reserved) for Date and Time in JavaReference − Oracle JavaLetterDate or Time ComponentPresentationExamplesGEra designatorTextADYYearYear1996; 96YWeek yearYear2009; 09MMonth in yearMonthJuly; Jul; 07WWeek in yearNumber27WWeek in monthNumber2DDay in yearNumber189DDay in monthNumber10FDay of week in monthNumber2EDay name in weekTextTuesday; TueUDay number of week (1 = Monday, ..., 7 = Sunday)Number1AAm/pm markerTextPMHHour in day (0-23)Number0KHour in day (1-24)Number24KHour in am/pm (0-11)Number0hHour in am/pm (1-12)Number12mMinute in hourNumber30sSecond in minuteNumber55SMillisecondNumber978zTime zoneGeneral time zonePacific Standard Time; PST; GMT-08:00ZTime zoneRFC 822 time zone-800XTime zoneThe above pattern letters are combined ...

Read More

Convert.ToByte Method in C#

Arjun Thakur
Arjun Thakur
Updated on 11-Mar-2026 1K+ Views

The Convert.ToByte method is used to convert a specified value to an 8-bit unsigned integer.Let’s say we have a char variable.Char charVal = ‘a’;Now, convert it to an 8-bit unsigned integer.byte byteVal = Convert.ToByte(charVal);Let us see another example now.Exampleusing System; public class Demo {    public static void Main() {       char[] charVal = { 'p', 'q', 'r', 's' };       foreach (char c in charVal) {          byte byteVal = Convert.ToByte(c);          Console.WriteLine("{0} is converted to = {1}", c, byteVal);       }    } }Outputp is converted to = 112 q is converted to = 113 r is converted to = 114 s is converted to = 115

Read More

Convert.ToUInt64 Method in C#

Ankith Reddy
Ankith Reddy
Updated on 11-Mar-2026 196 Views

Use the Convert.ToUInt64() method to convert a specified value to a 64-bit unsigned integer.The following is our char.char ch = 'a';Now, let’s convert it to a 64-bit unsigned integer.ulong res; res = Convert.ToUInt64(ch);Here is the complete example.Exampleusing System; public class Demo {    public static void Main() {       char ch = 'a';       ulong res;       res = Convert.ToUInt64(ch);       Console.WriteLine("Converted char value '{0}' to {1}", ch, res);    } }OutputConverted char value 'a' to 97

Read More

Java Program to display date with day name in short format

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

Firstly, set the format with SimpleDateFormat classFormat dateFormat = new SimpleDateFormat("EEE, dd/MM/yyyy");Above, the “EEE” is set to display the name of the day i.e. Monday, Tuesday, Wednesday, etc.Now, to display the date −String res = dateFormat.format(new Date());The following is an example −Exampleimport java.text.Format; import java.text.SimpleDateFormat; import java.util.Date; public class Demo {    public static void main(String[] argv) throws Exception {       Format dateFormat = new SimpleDateFormat("EEE, dd/MM/yyyy");       String res = dateFormat.format(new Date());       System.out.println("Date = " + res);    } }OutputDate = Thu, 22/11/2018

Read More
Showing 7921–7930 of 25,433 articles
« Prev 1 791 792 793 794 795 2544 Next »
Advertisements