Java Coding
In Java, we can convert a lowercase string to an uppercase string using either the built-in toUpperCase() method or custom logic using loops. For example, if the input string is “Java”, it should be converted to “JAVA”. In this article, we will explore how to convert a lowercase string to uppercase using different approaches, along […]
Learn different ways to compare strings in Java using equals(), equalsIgnoreCase(), ==, and compareTo() methods. This guide includes step-by-step examples, logic breakdowns, and custom comparison techniques for better understanding. Required Knowledge Problem Statement Write a Java program to compare two strings and determine if they are equal. The program should accept two string inputs and […]
In java, to concatenate two strings we can use + (String concatenation) operator or concat() of the String class or StringBuilder class or StringJoiner class ( from java 8 version) or String.join() method. All these method can concatenate the two Strings in Java. For example, For given to input strings: string1 = Welcome to string2= […]
In java, to print the length of given string we can use default length() method of the String class or loop concept such as for loop. If the input string is “Hello” then the length of the string is 5. In this article we will learn writing Java program to print the length of the […]
In Java, to check whether a string is palindrome or not we can create a custom method to do string reversal (As custom method is more efficient and reusable) along with that we can also use two-pointer approach or String reversal approach. A String is known as palindrome String, If the reversed string is equal […]
In Java, to check whether a year is a leap year or not we can use conditional statements such as if else or switch statements. For a given input year, we have to print whether the year is leap year or not. In this program we will be using the switch statement to solve this […]
In Java, to find a reverse of a string is a common task. We can reverse a string with various methods available, such as using loops like while and for, or using StringBuilder for efficiency. For instance, reversing the String “hi” results in “ih”. In this article we will learn how to find reverse of […]
In mathematics, a matrix is a rectangular array of numbers arranged in rows and columns. Matrix multiplication is a vital operation in various applications like graphics transformations, solving systems of linear equations, and in algorithms across scientific computing, engineering, and deep learning. However, multiplying matrices isn’t as straightforward as multiplying individual elements. It involves a […]
Matrix addition is a basic arithmetic operation where two matrices of the same dimensions are added together to produce a new matrix. Each element of the resulting matrix is obtained by adding corresponding elements from the two matrices. This operation is vital in data science, physics, engineering, and more, where matrices are used to represent […]
In Java, to find percentage and grade of the students based on marks we can use if-else conditional statements or Ternary Operator. For example, if a student’s marks in each subject are 30, 45, 60, 90, and 67, the calculated percentage would be 58.40%, resulting in a grade of E. In this article, we are […]