Samual Sam

Samual Sam

1,507 Articles Published

Articles by Samual Sam

Page 83 of 151

Enum for days of week in Java

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

To set enum for days of the week, set them as constantsenum Days { Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday }Now create objects and set the above constants −Days today = Days.Wednesday; Days holiday = Days.Sunday;The following is an example −Examplepublic class Demo {    enum Days {       Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday    }    public static void main(String[] args) {       Days today = Days.Wednesday;       Days holiday = Days.Sunday;       System.out.println("Today = " + today);       System.out.println(holiday+ " is holiday");    } }OutputToday = Wednesday Sunday is holiday

Read More

Java Program to use == operator to compare enums

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

We can use the == operator to compare enums in Java.Let’s say we have the following enum.enum Devices {    LAPTOP, MOBILE, TABLET; }Here are some of the objects and we have assigned some values as well −Devices d1, d2, d3; d1 = Devices.LAPTOP; d2 = Devices.LAPTOP; d3 = Devices.TABLET;Let us now see an example wherein we will compare them using == operator −Examplepublic class Demo {    enum Devices {       LAPTOP, MOBILE, TABLET;    }    public static void main(String[] args) {       Devices d1, d2, d3;       d1 = Devices.LAPTOP;   ...

Read More

Java Program to check whether the character is ASCII 7 bit

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

To check whether the character is ASCII 7 bit or not, check whether given value’s ASCII value is less than 128 or not.Here, we have a character.char one = '-';Now, we have checked a condition with if-else for ASCII 7-bit character.if (c < 128) { System.out.println("Given value is ASCII 7 bit!"); } else {    System.out.println("Given value is not an ASCII 7 bit!"); }The following is an example wherein we check a character for ASCII 7-bit.Examplepublic class Demo {    public static void main(String []args) {       char c = '-';       System.out.println("Given value = "+c); ...

Read More

Create BigInteger via string in Java

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

BigInteger class is used for big integer calculations which are outside the limit of the primitive data types. It provides operations for modular arithmetic, GCD calculation, primality testing, prime generation, bit manipulation, and a few other miscellaneous operations.Firstly, set a string −String str = "268787878787687";Now, create a new object for BigInteger and pass the above string −BigInteger bInteger = new BigInteger(str);The following is an example −Exampleimport java.math.BigInteger; public class Demo {    public static void main(String[] argv) throws Exception {       String str = "268787878787687";       BigInteger bInteger = new BigInteger(str);       System.out.println(bInteger);    } }Output268787878787687

Read More

Create BigInteger from byte array in Java

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

BigInteger class provides operations for modular arithmetic, GCD calculation, primality testing, prime generation, bit manipulation, and a few other miscellaneous operations.Let’s say the following is our byte array −byte[] arr = new byte[] { 0x1, 0x00, 0x00 };We will now convert them to BigInteger −BigInteger bInteger = new BigInteger(arr);The following is an example that creates BigInteger from a byte array in Java.Exampleimport java.math.BigInteger; public class Demo {    public static void main(String[] argv) throws Exception {       byte[] arr = new byte[] { 0x1, 0x00, 0x00 };       BigInteger bInteger = new BigInteger(arr);       System.out.println(bInteger);    } }Output65536

Read More

Bootstrap class pull-right

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

Float an element to the right with class pull-right.You can try to run the following code to implement the pull-right classExample           Bootstrap Example                                          Float to right          

Read More

Caret Bootstrap class

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

Use carets to indicate dropdown functionality and direction. To get this functionality use the class caret with a element.You can try to run the following code to implement caret Bootstrap classExample           Bootstrap Example                                 Caret Example    

Read More

Regex in Python to put spaces between words starting with capital letters

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

The problem we are trying to solve here is to convert CamelCase to separate out words. We can solve this directly using regexes by finding all occurrences of a capital letter in the given string and put a space before it. We can use the sub method from the re module.For example, for the input string −AReallyLongVariableNameInJavaWe should get the output −A Really Long Variable Name In JavaWe can use "[A-Z]" regex to find all uppercase letters, then replace them with space and that letter again. We can implement it using the re package as follows −Exampleimport re # ...

Read More

Comparison of autoboxed integer object in Java

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

When we assigned an int to Integer object, it is first converted to an Integer Object and then assigned. This process is termed as autoboxing. But there are certain things which you should consider while comparison of such objects using == operator. See the below example first.Examplepublic class Tester {    public static void main(String[] args) {       Integer i1 = new Integer(100);       Integer i2 = 100;               //Scenario 1:       System.out.println("Scenario 1: " + (i1 == i2));       Integer i3 = 100; ...

Read More

Vertical Buttongroup with Bootstrap

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

The btn-group-vertical class makes a set of buttons appear vertically stacked rather than horizontally.You can try to run the following code to work with a vertical button groupExample           Bootstrap Example                                          BCA          B.Tech                                      Masters                span class = "caret">                                        MCA                MBA                M.Tech                M.COM                                

Read More
Showing 821–830 of 1,507 articles
« Prev 1 81 82 83 84 85 151 Next »
Advertisements