karthikeya Boyini

karthikeya Boyini

1,421 Articles Published

Articles by karthikeya Boyini

Page 70 of 143

Return the total elements in a sequence as a 64-bit signed integer in C#

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

Firstly, set a string array.string[] num = { "One", "Two", "Three", "Four", "Five"};Use the Linq LongCount method to get the count of elements.num.AsQueryable().LongCount();Here is the complete code −Exampleusing System; using System.Collections.Generic; using System.Linq; class Demo {    static void Main() {       string[] num = { "One", "Two", "Three", "Four", "Five"};       long res = num.AsQueryable().LongCount();       Console.WriteLine("{0} elements", res);    } }Output5 elements

Read More

C# program to print all distinct elements of a given integer array in C#

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

We have set an array and a dictionary to get the distinct elements.int[] arr = {    88,    23,    56,    96,    43 }; var d = new Dictionary < int, int > ();Dictionary collection allows us to get the key and value of a list.The following is the code to display distinct elements of a given integer array −Exampleusing System; using System.Collections.Generic; namespace Demo {    public class Program {       public static void Main(string[] args) {          int[] arr = {             88,     ...

Read More

Object Initializer in C#

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

Initialize an object of a class with object initialize.Using it, you can assign values to the fields at the time of creating an object.We created Employee object and assigned values using curly bracket at the same time.Employee empDetails = new Employee() {    EID = 10,    EmpName = "Tim",    EmpDept = "Finance" }Now access the values of the Employee class. For example, for name of the employee.empDetails.EmpNameLet us see the complete code −Exampleusing System; public class Demo {    public static void Main() {       Employee empDetails = new Employee() {          EID ...

Read More

What are annotations in Java?

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

Annotations are a tag (metadata) which provides info about a program. Annotations in Java Start with the symbol ‘@’. They are used by the compiler to detect errors. Software tools to generate code. They are used to show attributes of an element: e.g. @Deprecated, @Override. Annotation are used to describe the purpose of an element of the framework, e.g. @Entity, @TestCase, @WebService Annotations describe the behaviour of an element: @Statefull, @Transaction. Example class Sample{ public void display(){ System.out.println(" "); } } public class Test extends ...

Read More

What's the simplest way to print a Java array?

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

Generally, to print the contents of an array you need to use for loops, in addition to that you can directly print an array using the toString() method of this class. This method accepts an array as a parameter and returns it in String format.Exampleimport java.util.Arrays; public class PrintingArrays {    public static void main(String args[]) {       int[] myArray = {23, 93, 30, 56, 92, 39};       System.out.println(Arrays.toString(myArray));    } }Output[23, 93, 30, 56, 92, 39]

Read More

Java Program to count letters in a String

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

Let’s say we have the following string, that has some letters and numbers.String str = "9as78";Now loop through the length of this string and use the Character.isLetter() method. Within that, use the charAt() method to check for each character/ number in the string.for (int i = 0; i < str.length(); i++) {    if (Character.isLetter(str.charAt(i)))    count++; }We have set a count variable above to get the length of the letters in the string.Here’s the complete example.Examplepublic class Demo {    public static void main(String []args) {       String str = "9as78";       int count = ...

Read More

Java Program to convert ASCII code to String

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

To convert ASCII to string, use the toString() method. Using this method will return the associated character.Let’s say we have the following int value, which works as ASCII for us.int asciiVal = 89;Now, use the toString() method.String str = new Character((char) asciiVal).toString();Examplepublic class Demo {    public static void main(String []args) {       int asciiVal = 87;       String str = new Character((char) asciiVal).toString();       System.out.println(str);    } }OutputW

Read More

Split String with Comma (,) in Java

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

Let’s say the following is our string.String str = " This is demo text, and demo line!";To split a string with comma, use the split() method in Java.str.split("[,]", 0);The following is the complete example.Examplepublic class Demo {     public static void main(String[] args) {        String str = "This is demo text, and demo line!";        String[] res = str.split("[,]", 0);        for(String myStr: res) {           System.out.println(myStr);        }     } }OutputThis is demo text and demo line!

Read More

C# Program to check if a number is prime or not

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

To calculate whether a number is prime or not, we have used a for loop. Within that on every iteration, we use an if statement to find that the remainder is equal to 0, between the number itself.for (int i = 1; i

Read More

C# Program to Convert Integer to String

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

To convert an integer to string in C#, use the ToString() method.Set the integer for which you want the string −int num = 299;Use the ToString() method to convert Integer to String −String s; int num = 299; s = num.ToString();ExampleYou can try to run the following code to convert an integer to string in C# −using System; class MyApplication {    static void Main(string[] args) {       String s;       int num = 299;       s = num.ToString();       Console.WriteLine("String = "+s);       Console.ReadLine();    } }OutputString = 299

Read More
Showing 691–700 of 1,421 articles
« Prev 1 68 69 70 71 72 143 Next »
Advertisements