Articles on Trending Technologies

Technical articles with clear explanations and examples

CHAR_BIT in C++

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

The CHAR_BIT is the number of bits in char. It is declared in “limits.h” header file in C++ language. It is of 8-bits per byte.Here is an example of CHAR_BIT in C++ language,Example#include using namespace std; int main() {    int x = 28;    int a = CHAR_BIT*sizeof(x);    stack s;    cout

Read More

Convert Short into String in Java

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

Using toString() method to convert Short to string. Firstly, let us take a short primitive datatype and initialize a short value.short myShort = 55;Now let us include this value to the following Short object.Short s = new Short(myShort);Convert the above given Short to string using the toString() method as shown in the complete example below.Examplepublic class Demo {    public static void main(String []args) {       short myShort = 55;       Short s = new Short(myShort);       System.out.println("Short: "+s);       String myStr = s.toString();       System.out.println("String: "+myStr);    } }OutputShort: 55 String: 55

Read More

Convert short primitive type to Short object in Java

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

Let us first create a short primitive type and assign a value.short val = 30;Now, create a Short object and set the above short type to it.Short myShort = new Short(val);The following is the complete example to convert short primitive type to Short object using Short constructor.Examplepublic class Demo {    public static void main(String []args) {       short val = 30;       Short myShort = new Short(val);       System.out.println(myShort);    } }Output30

Read More

Get the last element from a Sorted Set in Java

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

To create a Sorted Set, firstly create a Set −Set s = new HashSet();Add elements to the above set −int a[] = {77, 23, 4, 66, 99, 112, 45, 56, 39, 89}; Set s = new HashSet(); try {    for(int i = 0; i < 5; i++) {    s.add(a[i]); }After that, use TreeSet class to sort −TreeSet sorted = new TreeSet(s);Get the last element, using the last() method −System.out.println("Last element of the sorted set = "+ (Integer)sorted.last());The following is the code to get the last element from a Sorted Set in Java −Exampleimport java.util.*; public class Demo { ...

Read More

Ceil and floor functions in C++

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

The ceil FunctionThe ceil function returns the smallest possible integer value which is equal to the value or greater than that. This function is declared in “cmath” header file in C++ language. It takes single value whoes ceil value is to be calculated. The datatype of variable should be double/float/long double only.Here is the syntax of ceil function in C++ language,double ceil(double x); float ceil(float x);Here is an example of ceil function in C++ language,Example#include #include using namespace std; int main() {    float var = 1234.25;    float res;    res = ceil(var);    cout

Read More

Check whether a NavigableMap empty or not in Java

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

The isEmpty() method is used in Java to check whether a NavigableMap is empty or not.First, create a NavigableMap and add elements to it −NavigableMap n = new TreeMap(); n.put(5, "Tom"); n.put(9, "John"); n.put(14, "Jamie"); n.put(1, "Tim"); n.put(4, "Jackie"); n.put(15, "Kurt"); n.put(19, "Tiger"); n.put(24, "Jacob");Now, check whether the Map is empty or not −System.out.println("Map is empty? " + n.isEmpty());The following is an example to implement isEmpty() method and check whether the Map is empty −Exampleimport java.util.*; public class Demo {    public static void main(String[] args) {       NavigableMap n = new TreeMap();       n.put(5, "Tom"); ...

Read More

C++ Program to Check Whether Number is Even or Odd

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

A number is even if it is divisible by two and odd if it is not divisible by two.Some of the even numbers are −2, 4, 6, 8, 10, 12, 14, 16Some of the odd numbers are −1, 3, 5, 7, 9, 11, 13, 15, 17Check Whether Number is Even or Odd using ModulusA program to check whether number is even or odd using modulus is as follows.Example#include using namespace std; int main() {    int num = 25;    if(num % 2 == 0)    cout

Read More

Const member functions in C++

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

The const member functions are the functions which are declared as constant in the program. The object called by these functions cannot be modified. It is recommended to use const keyword so that accidental changes to object are avoided.A const member function can be called by any type of object. Non-const functions can be called by non-const objects only.Here is the syntax of const member function in C++ language, datatype function_name const();Here is an example of const member function in C++, Example#include using namespace std; class Demo {    int val;    public:    Demo(int x = 0) {   ...

Read More

How to compile assert in Java?

Smita Kapse
Smita Kapse
Updated on 11-Mar-2026 734 Views

In order to compile assert in Java, we simply set the boolean expression as false.Let us see an example program −Examplepublic class Example {    public static void main(String[] args) {       assert false;       System.out.println("Compiled and executed successfully!!!");    } }OutputCompiled and executed successfully!!!

Read More

Get Day Number of Week in Java

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

To get the day of the week, use Calendar.DAY_OF_WEEK.Firstly, declare a calendar object and get the current date and time.Calendar calendar = Calendar.getInstance(); System.out.println(calendar.getTime().toString());Now, fetch the day of the week in an integer variable.int day = calendar.get(Calendar.DAY_OF_WEEK);The following is the final example.Exampleimport java.util.Calendar; public class Demo {    public static void main(String[] args) {       Calendar calendar = Calendar.getInstance();       System.out.println(calendar.getTime().toString());       int day = calendar.get(Calendar.DAY_OF_WEEK);       System.out.println("Day: " + day);       int hour = calendar.get(Calendar.HOUR_OF_DAY);       System.out.println("Hour: " + hour);       int minute = calendar.get(Calendar.MINUTE); ...

Read More
Showing 29541–29550 of 61,297 articles
Advertisements