java

Java String Function getBytes()

The java string getBytes() method returns the byte array of the string. In other words, it returns sequence of bytes. Java String getBytes() method example public class StringGetBytesExample{ public static void main(String args[]){ String s1=”ABCDEFG”; byte[] barr=s1.getBytes(); for(int i=0;i < barr.length;i++){ System.out.println(barr[i]); } }} Output: 65 66 67 68 69 70 71

Java String Function format()

The java string format() method returns the formatted string by given locale, format and arguments. If you don’t specify the locale in String.format() method, it uses default locale by calling Locale.getDefault() method. The format() method of java language is like sprintf() function in c language and printf() method of java language. Java String format() method […]

Java String function equalsIgnoreCase()

The String equalsIgnoreCase() method compares the two given strings on the basis of content of the string irrespective of case of the string. It is like equals() method but doesn’t check case. If any character is not matched, it returns false otherwise it returns true. Java String equalsIgnoreCase() method example public class EqualsIgnoreCaseExample{ public static […]

Java String Function equals()

The java string equals() method compares the two given strings based on the content of the string. If any character is not matched, it returns false. If all characters are matched, it returns true. The String equals() method overrides the equals() method of Object class. Java String equals() method example public class EqualsExample{ public static […]

Java Object Oriented Programming (OOPs) Concepts

Java is an Object Oriented Programming language. There are many object oriented features in java such as Inheritance, Polymorphism, Abstraction, Encapsulation etc.

The first object-oriented programming language is Simula.
Java is known as truly object-oriented programming language because all java programs is written in class.

Short Name Format Program in Java

Short Name Format Program in Java

Ugly Number Program in Java

A number is said to be an Ugly number if positive numbers whose prime factors only include 2, 3, 5.
For example, 6(2×3), 8(2x2x2), 15(3×5) are ugly numbers while 14(2×7) is not ugly since it includes another prime factor 7. Note that 1 is typically treated as an ugly number.

Pronic Number Program in Java

A number is said to be a pronic number if product of two consecutive integers is equal to the number, is called a pronic number.
Example- 42 is said to be a pronic number, 42=6×7, here 6 and 7 are consecutive integers

Magic Number Program in Java

Magic number is the if the sum of its digits recursively are calculated till a single digit If the single digit is 1 then the number is a magic number. Magic number is very similar with Happy Number.

Prime Number Up to N Terms Program in Java

Prime Number Up to N Terms Program in Java. Ex: Enter size of prime=5
Number is prime=2
Number is prime=3
Number is prime=5
Number is prime=7
Number is prime=11
Number is prime=13

1 2 3 4 12