karthikeya Boyini

karthikeya Boyini

1,421 Articles Published

Articles by karthikeya Boyini

Page 38 of 143

Align Dropdown to the right with Bootstrap

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

To align dropdown to the right, add the class .pull-right to .dropdown-menu. You can try to run the following code to align dropdown to the rightExample           Bootstrap Example                                                       Cars                                                            BMW                                        Audi                                                           Hyundai                                                                           Mitsubishi                                                                           Nissan                                                

Read More

What is method overloading in C#?

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

Two or more than two methods having the same name but different parameters is what we call method overloading in C#.Method overloading in C# can be performed by changing the number of arguments and the data type of the arguments.Let’s say you have a function that prints multiplication of numbers, then our overloaded methods will have the same name but different number of arguments −public static int mulDisplay(int one, int two) { } public static int mulDisplay(int one, int two, int three) { } public static int mulDisplay(int one, int two, int three, int four) { }The following is an ...

Read More

Comparison of double and float primitive types in Java\\n

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

If we compare a float and a double value with .5 or .0 or .1235 (ending with 5 or 0), then == operator returns true, otherwise it will return false. See the below example.Examplepublic class Tester {    public static void main(String[] args) {       double d1 = 2.5;       float f1 = 2.5f;       System.out.println(d1 == f1);       double d2 = 2.4;       float f2 = 2.4f;       double margin = 0.0000001;       System.out.println(compareNumbers(d2, f2, margin));    }      private static boolean compareNumbers(double d, float f, double margin) {       if(Math.abs(d - f) < margin) {          return true;       }               return false;    } }Outputtrue true

Read More

Python program to sort out words of the sentence in ascending order

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

In order to sort the words of a sentence in ascending order, we first need to split the sentence into words using space as the splitting point. For simplicity, we'll only be splitting on space and let the punctuation be there. We can use replace or regex to remove that as well.Once we split the sentence, we can sort the words lexicographically(like in a language dictionary) using either sort or sorted methods depending on whether we want to sort the array in place or sort it, then return a new array.In place sorting: when we want to sort the array/list ...

Read More

C# Program to replace a special character from a String

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

Let’s say our string is −string str = "abcd$ef$gh";To replace the special character, use the Replace() method.string res = str.Replace('$', 'k');The following is the complete code to replace character from a string −Exampleusing System; public class Program {    public static void Main() {       string str = "abcd$ef$gh";       Console.WriteLine("Initial string = " + str);       string res = str.Replace('$', 'k');       // after replacing       Console.WriteLine("Replaced string = " + res.ToString());    } }OutputInitial string = abcd$ef$gh Replaced string = abcdkefkgh

Read More

How to clear screen using C#?

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

Use the Console.Clear() method to clear screen and the console buffer. When the Clear method is called, the cursor automatically scrolls to the top-left corner of the window.Here, we have cleared the screen and then set the ForegroundColor and BackgroundColor −ConsoleColor newForeColor = ConsoleColor.Blue; ConsoleColor newBackColor = ConsoleColor.Yellow;The following is the complete code −Exampleusing System; using System.Collections.Generic; class Program {    static void Main() {       ConsoleColor foreColor = Console.ForegroundColor;       ConsoleColor backColor = Console.BackgroundColor;       Console.WriteLine("Clearing the screen!");       Console.Clear();       ConsoleColor newForeColor = ConsoleColor.Blue;       ConsoleColor newBackColor = ConsoleColor.Yellow;    } }OutputClearing the screen!

Read More

Compare the content of two StringBuilders

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

Equals method is used in C# to compare the content of two StringBuilders.The following are our two StringBuilders −// first StringBuilder str1 = new StringBuilder(); str1.Append("Tim"); str1.Append("Tom"); str1.Append("Henry"); // second StringBuilder str2 = new StringBuilder(); str2.Append("John"); str2.Append("David"); str2.Append("Beth");Now use the Equals() method to compare both the methods −if (str1.Equals(str2)) {    Console.WriteLine("Contents are equal!"); }The following is the complete code −Exampleusing System; using System.Text; class Demo {    static void Main() {       // first       StringBuilder str1 = new StringBuilder();       str1.Append("Tim");       str1.Append("Tom");       str1.Append("Henry"); ...

Read More

Clear a StringBuilder in C#

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

To clear a StringBuilder, use the Clear() method.Let’s say we have set the following StringBuilder −string[] myStr = { "One", "Two", "Three", "Four" }; StringBuilder str = new StringBuilder("We will print now...").AppendLine();Now, use the Clear() method to clear the StringBuilder −str.Clear();Let us see the complete code −Exampleusing System; using System.Text; public class Demo {    public static void Main() {       // string array       string[] myStr = { "One", "Two", "Three", "Four" };       StringBuilder str = new StringBuilder("We will print now...").AppendLine();       // foreach loop to append elements ...

Read More

Assigning long values carefully in java to avoid overflow\\n

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

In case of having the operation of integer values in Java, we need to be aware of int underflow and overflow conditions. Considering the fact that in Java, The int data type is a 32-bit signed two's complement integer having a minimum value of -2, 147, 483, 648 and a maximum value of 2, 147, 483, 647. If a value goes beyond the max value possible, the value goes back to minimum value and continue from that minimum. In a similar way, it happens for a value less than the min value. Consider the following example.Examplepublic class Tester {   ...

Read More

C# Program to change a character from a string

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

Let's say our string is −StringBuilder str = new StringBuilder(); str.Append("pre");To change a character, set the value at that particular index. The following sets a character at the 3rd position −str[2] = 'o';Here is the complete code −Exampleusing System; using System.Text; public class Demo {    public static void Main() {       StringBuilder str = new StringBuilder();       str.Append("pre");       Console.WriteLine("String : "+str);       Console.WriteLine("Change 3rd character");       str[2] = 'o';       Console.WriteLine("New String : "+str);    } }OutputString : pre Change 3rd character New String : pro

Read More
Showing 371–380 of 1,421 articles
« Prev 1 36 37 38 39 40 143 Next »
Advertisements