karthikeya Boyini

karthikeya Boyini

1,421 Articles Published

Articles by karthikeya Boyini

Page 20 of 143

Boolean Type in Java

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

To display Boolean type, firstly take two variables and declare them as boolean.boolean val1, val2;Then one by one assign values to both of them, one of them is shown below −val1 = true;Now, use if statement to check and display the Boolean true value.if(val1) System.out.println("This is true and will get displayed!");Let us now see the complete example to work with Boolean Type in Java.Examplepublic class Demo {    public static void main(String[] args) {       boolean val1, val2;       System.out.println("Boolean Type in Java");       val1 = true;       if(val1)       ...

Read More

DataView.byteLength property in JavaScript

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

The byteLength property of the DataView represents the length of the current Data View.SyntaxIts syntax is as followsdataView.byteLength();Example    JavaScript Example           var arrayBuffer = new ArrayBuffer(8);       var dataView = new DataView(arrayBuffer);       document.write(dataView.byteLength);     Output8

Read More

Join Strings in Java

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

To join strings in Java, use the String.join() method. The delimiter set as the first parameter in the method is copied for each element.Let’s say we want to join the strings “Demo” and “Text”. With that, we want to set a delimeter $. For that, use the join() method as shown below −String.join("$","Demo","Text");The following is an example.Examplepublic class Demo {    public static void main(String[] args) {       String str = String.join("$","Demo","Text");       System.out.println("Joined strings: "+str);    } }OutputJoined strings: Demo$Text

Read More

Difference between TimeSpan Seconds() and TotalSeconds()

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

TimeSpan Seconds() is part of time, whereas TimeSpan TotalSeconds() converts entire time to seconds.Let us first see the TimeSpan Seconds() method.Exampleusing System; using System.Linq; public class Demo {    public static void Main() {       TimeSpan ts = new TimeSpan(0, 100, 0, 20, 0);       // seconds       Console.WriteLine(ts.Seconds);    } }Output20Now, let us see how TotalSeconds works for the same TimeSpan value.Exampleusing System; using System.Linq; public class Demo {    public static void Main() {       TimeSpan ts = new TimeSpan(0, 100, 0, 20, 0);       // total seconds ...

Read More

DataView.buffer property in JavaScript

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

The buffer property of the DataView represents the ArrayBuffer of the current DataView.SyntaxIts syntax is as followsdataView.buffer;ExampleTry the following example.    JavaScript Example           var arrayBuffer = new ArrayBuffer(156);       var dataView = new DataView(arrayBuffer);       document.write(dataView.buffer.byteLength);     Output156

Read More

Get the substring after the first occurrence of a separator in Java

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

We have the following string with a separator.String str = "Tom-Hanks";We want the substring after the first occurrence of the separator i.e.HanksFor that, first you need to get the index of the separator and then using the substring() method get, the substring after the separator.String separator ="-"; int sepPos = str.indexOf(separator); System.out.println("Substring after separator = "+str.substring(sepPos + separator.length()));The following is an example.Examplepublic class Demo {    public static void main(String[] args) {       String str = "Tom-Hanks";       String separator ="-";       int sepPos = str.indexOf(separator);       if (sepPos == -1) { ...

Read More

Get the substring before the last occurrence of a separator in Java

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

We have the following string with a separator.String str = "David-Warner";We want the substring before the last occurrence of a separator. Use the lastIndexOf() method.For that, you need to get the index of the separator using indexOf()String separator ="-"; int sepPos = str.lastIndexOf(separator); System.out.println("Substring before last separator = "+str.substring(0, sepPos));The following is an example.Examplepublic class Demo {    public static void main(String[] args) {       String str = "David-Warner";       String separator ="-";       int sepPos = str.lastIndexOf(separator);       if (sepPos == -1) {          System.out.println("");       ...

Read More

Convert Long to numeric primitive data types in Java

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

Let’s say we have Long object here.Long myObj = new Long("9879");Now, if we want to convert this Long to short primitive data type. For that, use the in-built shortValue() method −// converting to short primitive types short shortObj = myObj.shortValue(); System.out.println(shortObj);In the same way convert Long to another numeric primitive data type int. For that, use the in-built intValue() method −// converting to int primitive types int intObj = myObj.intValue(); System.out.println(intObj);The following is an example wherein we convert Long to numeric primitive types short, int, float, etc −Examplepublic class Demo { public static void main(String[] args) { ...

Read More

C# Program to merge sequences

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

Let’s add two sequences.Integer Array.int[] intArray = { 1, 2, 3, 4, 5, 6, 7, 8 };String Array.string[] stringArray = { "Depp", "Cruise", "Pitt", "Clooney", "Sandler", "Affleck", "Tarantino" };Now to merge both the above sequences, use the Zip method.ntArray.AsQueryable().Zip(stringArray, (one, two) => one + " " + two);Let us see the complete code.Exampleusing System; using System.Linq; using System.Collections.Generic; public class Demo {    public static void Main() {       int[] intArray = { 1, 2, 3, 4, 5, 6, 7, 8 };       string[] stringArray = { "Depp", "Cruise", "Pitt", "Clooney", "Sandler", "Affleck", "Tarantino"       };       var mergedSeq = intArray.AsQueryable().Zip(stringArray, (one, two) => one + " " + two);       foreach (var ele in mergedSeq)       Console.WriteLine(ele);    } }Output1 Depp 2 Cruise 3 Pitt 4 Clooney 5 Sandler 6 Affleck 7 Tarantino

Read More

“register” keyword in C

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

Register variables tell the compiler to store the variable in CPU register instead of memory. Frequently used variables are kept in registers and they have faster accessibility. We can never get the addresses of these variables. “register” keyword is used to declare the register variables.Scope − They are local to the function.Default value − Default initialized value is the garbage value.Lifetime − Till the end of the execution of the block in which it is defined.Here is an example of register variable in C language, Example#include int main() {    register char x = 'S';    register int a ...

Read More
Showing 191–200 of 1,421 articles
« Prev 1 18 19 20 21 22 143 Next »
Advertisements