# java programs

- 30 March
### Implement isPrime method in java

In this post, we will implement isPrime method. isPrime method will take an integer as input and determine whether the number is prime or number. A prime number is a number which has only two divisors 1 and itself. To check if the number is prime or not, we need to see if it has any […]

- 10 March
### Print pyramid pattern: 1 3*2 4*5*6 pattern in java

In this post, we will see how to print the following pyramid pattern. Problem Input : n = 4 Output : 1 3*2 4*5*6 10*9*8*7Input : n = 5 Output : 1 3*2 4*5*6 10*9*8*7 11*12*13*14*15 Solution If you notice the pattern we need to print odd rows in increasing order and even rows in […]

- 22 January
### Matrix multiplication in java

In this post, we will see how to multiply two matrices in java. [crayon-609346e2d36ce798653147/] Output: Enter number of rows and columns of first matrix : 2 2 Enter first matrix elements : 2 4 6 8 Enter number of rows and columns of second matrix :2 2 Enter second matrix elements : 3 6 9 […]

- 22 January
### Java program to add two matrices

In this post, we will see how to add two matrices in java.I am giving example for 33 matrix. You can extend it to nn matrices. [crayon-609346e2d3a46157989507/] Output: Enter matrix 1 elements : 11 22 33 44 55 66 77 88 99 Enter matrix 2 elements : 10 20 30 40 50 60 70 80 […]

- 22 January
### Java program to subtract two matrices

In this post, we will see how to subtract two matrices in java.I am giving example for 33 matrix. You can extend it to nn matrices. [crayon-609346e2d3d81339312026/] Output: Enter Matrix 1 Elements : 11 22 33 44 55 66 77 88 99 Enter Matrix 2 Elements : 10 20 30 40 50 60 70 80 […]

- 22 January
### Convert celsius to fahrenheit in java

In this tutorial, we will see simple java program to convert celsius to fahrenheit in java. You can convert celsius to fahrenheit using this formula. fh = (1.8*cen) + 32; [crayon-609346e2d40fa576063889/] Output: Enter Temperature in Centigrade : 30 Equivalent Temperature in Fahrenheit = 86.0

- 22 January
### Convert fahrenheit to celsius in java

In this tutorial, we will see simple java program to convert fahrenheit to celsius in java. You can convert fahrenheit to celsius using this formula. cel = (fh-32) / 1.8; [crayon-609346e2d442a454477411/] Output: Enter Temperature in Fahrenheit : 79 Equivalent Temperature in Celsius : 26.11111111111111

- 20 January
### Java program to delete words from sentence

In this post, we will see how to delete words from the sentence. You can just use String’s replaceAll method to replace the word with empty String(""). Here is simple java program to delete words from the sentence. [crayon-609346e2d4700436940101/] Output: Enter a String : Java2Blog is a technical blog. Enter a Word you want to […]

- 20 January
### Java program to remove vowels from String

In this tutorial we will see how to remove vowels from String in java. Using replaceAll() method We will use String’s replaceAll() method to remove vowels from String. [crayon-609346e2d4a1a974945580/] Output: Enter a String : Java2Blog All Vowels Removed Successfully..!! New String is : Jv2Blg Explaination Take input String from Scanner str1 Call replaceAll() method on […]