Ankith Reddy

Ankith Reddy

730 Articles Published

Articles by Ankith Reddy

Page 9 of 73

Initialize HashSet in Java

Ankith Reddy
Ankith Reddy
Updated on 11-Mar-2026 16K+ Views

A set is a collection which does not allows duplicate values. HashSet is an implementation of a Set. Following are the ways in which we can initialize a HashSet in Java.Using constructor − Pass a collection to Constructor to initialize an HashSet.Using addAll() − Pass a collection to Collections.addAll() to initialize an HashSet.Using unmodifiableSet() − Pass a collection to Collections.unmodifiableSet() to get a unmodifiable Set.Using add() − Using add(element) method of Set.Following is an example of using above ways.ExampleInfinityNow consider the following code snippet.Exampleimport java.util.Arrays; import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Set; public class Tester{    public static ...

Read More

Get the unqualified name of a class in Java

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

A qualified class name in Java contains the package that the class originated from. In contrast to this, the unqualified class name contains only the class name without any package information. A program that gets the unqualified name of a class is given as follows:Examplepublic class Demo {    public static void main(String[] argv) throws Exception {       Class c = java.util.ArrayList.class;       String className = c.getName();       System.out.println("The qualified class name is: " + className);       if (className.lastIndexOf('.') < 0) {          className = className.substring(className.lastIndexOf('.') + 1);     ...

Read More

C# Program to find a key in Dictionary

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

Firstly, set a Dictionary collection with elements.Dictionary d = new Dictionary() {    {1, "Applianes"},    {2, "Clothing"},    {3, "Toys"},    {4, "Footwear"},    {5, "Accessories"} };Now, let’s say you need to check whether key 5 exists or not. For that, use ContainsKey() method. It returns True if key is found.d.ContainsKey(5);Let us see the complete code.Exampleusing System; using System.Collections.Generic; public class Program {    public static void Main() {       Dictionary d = new Dictionary() {          {1, "Electronics"},          {2, "Clothing"},          {3, "Toys"},       ...

Read More

Using reflection to check array type and length in Java

Ankith Reddy
Ankith Reddy
Updated on 11-Mar-2026 2K+ Views

The array type can be checked using the java.lang.Class.getComponentType() method. This method returns the class that represents the component type of the array. The array length can be obtained in int form using the method java.lang.reflect.Array.getLength().A program that demonstrates this is given as follows −Exampleimport java.lang.reflect.Array; public class Demo {    public static void main (String args[]) {       int[] arr = {6, 1, 9, 3, 7};       Class c = arr.getClass();       if (c.isArray()) {          Class arrayType = c.getComponentType();          System.out.println("The array is of type: " ...

Read More

Convert.ToUInt64 Method in C#

Ankith Reddy
Ankith Reddy
Updated on 11-Mar-2026 201 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

C# Program to access tuple elements

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

Create a tuple.var myTuple = Tuple.Create(1, 2.5M, "Amit", "100");Now to access tuple elements, use the properties.To access first element.myTuple.Item1To access second element.myTuple.Item2In the same way, for other elements, use the properties as shown below −Exampleusing System; public class Program {    public static void Main() {       var myTuple = Tuple.Create(1, 2.5M, "Amit", "100");       Console.WriteLine("Item1 : "+ myTuple.Item1);       Console.WriteLine("Item2 : "+ myTuple.Item2);       Console.WriteLine("Item3 : "+ myTuple.Item3);       Console.WriteLine("Item4 : "+ myTuple.Item4);    } }OutputItem1 : 1 Item2 : 2.5 Item3 : Amit Item4 : 100

Read More

Constructor Overloading in C#

Ankith Reddy
Ankith Reddy
Updated on 11-Mar-2026 3K+ Views

When more than one constructor with the same name is defined in the same class, they are called overloaded, if the parameters are different for each constructor.Let us see an example to learn how to work with Constructor Overloading in C#.In the example, we have two subjects and a string declaration for Student Name.private double SubjectOne; private double SubjectTwo; string StudentName;We are showing result of three students in different subjects. For our example, to show constructor overloading, the name is only displayed for student 3rd.Student s1 = new Student(); Student s2 = new Student(90); Student s3 = new Student("Amit", 88, ...

Read More

Get floor value of a number using Math.floor in Java

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

To get the floor value of a number, we use the java.lang.Math.floor() method. The Math.floor() method returns the largest (closest to positive infinity) double value which is less than or equal to the parameter and has a value which is equal to a mathematical integer on the number line. If the parameter is NaN or an infinity or positive zero or negative zero, then the result is the same as the argument.Declaration - The java.lang.Math.floor() method is declared as follows −public static double floor(double a)Let us see a program to get the floor value of a number in Java.Exampleimport java.lang.Math; ...

Read More

Header files &ldquo;stdio.h&rdquo; and &ldquo;stdlib.h&rdquo; in C

Ankith Reddy
Ankith Reddy
Updated on 11-Mar-2026 16K+ Views

stdio.hThe header file stdio.h stands for Standard Input Output. It has the information related to input/output functions.Here is the table that displays some of the functions in stdio.h in C language, Sr.No.Functions & Description1printf()It is used to print the strings, integer, character etc on the output screen.2scanf()It reads the character, string, integer etc from the keyboard.3getc()It reads the character from the file.4putc()It writes the character to the file.5fopen()It opens the file and all file handling functions are defined in stdio.h header file.6fclose()It closes the opened file.7remove()It deletes the file.8fflush()It flushes the file.Here is an example of stdio.h in C language, ...

Read More

filter_has_var() function in PHP

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

The filter_has_var() function is used to check that variable of specified type exists or not.Syntaxfilter_has_var(type, var)Parameterstype − There are five types of inputs to check i.e. INPUT_GET, INPUT_POST, INPUT_COOKIE, INPUT_SERVER, or INPUT_ENV.var − The name of variable.ReturnThe filter_has_var() function returns true on success and false on failure.ExampleThe following is an example that is a quick check for the input variable "email”. The value INPUT_GET is used for this.

Read More
Showing 81–90 of 730 articles
« Prev 1 7 8 9 10 11 73 Next »
Advertisements