Core java
06 OctoberConvert char to lowercase java
You can use Character class’s toLowerCase method to convert char to lowercase in java. Method signature [crayon-6a29837c22582146893434/] Parameters ch is primitive character type. Return type return type is char. If char is already lowercase then it will return same. [crayon-6a29837c2258b267595967/] When you run above program, you will get below output: a y b z That’s […]
06 OctoberConvert char to uppercase java
You can use Charater class’s touppercase method to convert char to uppercase in java. Method signature [crayon-6a29837c22dc6463620451/] Parameters ch is primitive character type. Return type return type is char. If char is already uppercase then it will return same. [crayon-6a29837c22dce152032477/] When you run above program, you will get below output: A Y F U That’s […]
06 OctoberJava isLetter method
Character class’s isletter method can be used to check if character is letter or not. Method signature [crayon-6a29837c232ef208667317/] Parameters ch is primitive character type. Return type boolean is primitive character type. [crayon-6a29837c232f4295801015/] When you run above program, you will get below output: true true false false That’s all about java Character’s isletter method.
06 OctoberFix cannot make static reference to non-static method
In this post, we will see how to solve cannot make static reference to non-static method. Let’s understand this error with the help of example. [crayon-6a29837c237ff723487998/] Above program won’t compile and you will get below compilation error. It says cannot make static reference to non-static method sayHello from the type JavaHelloWorld Why are you getting […]
06 OctoberImplement distance formula in java
In this post, we will see how to implement distance formula between two points in java. Formula to find distance between two points ( x1, y1) and (x2 , y2) is d= sqrt( (x2-x1)^2+ (y2 – y1)^2) Here is simple program to calculate distance between two points in java. [crayon-6a29837c23c71211586455/] Here we have used math.sqrt […]
06 OctoberConvert decimal to binary in java
In this post, we will see how to convert decimal to binary in java. There are lot of ways to convert decimal to binary in java.Let’s explore them one by one. Using Integer.toBinaryString() method You can simply use inbuilt Integer.toBinaryString() method to convert a decimal [crayon-6a29837c24085796845667/] Output: Binary representation of 12 : 1100 Binary representation […]
05 OctoberCalculate total surface area of Cylinder in java
In this post, we will see how to calculate total surface area of Cylinder in java. Formula of calculating total surface area of Cylinder is: Surface area of Cylinder = 2 *Î * r * r + 2 *Î * r * h Where r is radius of cylinder and h is height of cylinder […]
05 OctoberCalculate total surface area of Hemisphere in java
In this post, we will see how to calculate total surface area of Hemisphere in java. Hemisphere is exactly half of sphere. There can be many practical examples of Hemisphere. You can divide earth into two hemisphere i.e. Northen Hemisphere and Southern Hemisphere. Formula of calculating total surface area of Hemisphere is: surface area of […]
05 OctoberGet Random Number between 0 and 1 in Java
In this post, we will see how to get random number between 0 to 1 in java. We have already seen random number generator in java. Get Random Number between 0 and 1 in Java We can simply use Math.random() method to get random number between 0 to 1. Math.random method returns double value between […]