Find Last Index of a Particular Word in a String in Java

Shiva Keerthi
Updated on 04-Nov-2024 18:44:29

584 Views

In Java, a string is also an object. It is the object of the String class. A String is a sequence of characters. The last index of a particular word in a string is nothing but the position of the last occurrence of that word in the string. The index of a character in a string defines or tells the position in the string. The position or Index always starts from 0. In this section, we are going to discuss how to implement a Java program to find the last index of a particular word in a string. Strings are ... Read More

Subtract Week from Current Date in Java

Samual Sam
Updated on 04-Nov-2024 18:44:16

936 Views

In this article, we will learn to subtract the week from the current date using Java. This is useful when you need to manipulate dates, such as calculating dates from previous weeks for scheduling or tracking purposes. We'll use two approaches: using the Calendar class and the LocalDate class, showcasing how to easily adjust dates. Problem Statement Write a program in Java to subtract a specified number of weeks from the current date and display the updated date − Input Run the program Output Current Date = Mon Nov 04 09:41:18 IST 2024 Updated Date = Mon Oct 21 09:41:18 ... Read More

Convert Array into Collection in Java

AmitDiwan
Updated on 04-Nov-2024 18:44:02

886 Views

In this article, we will understand how to convert the array into a collection in Java. The Collection is a framework that provides an architecture to store and manipulate the group of objects. Java Collections can achieve all the operations that you perform on data such as searching, sorting, insertion, manipulation, and deletion. Problem Statement Write a program in Java to convert the array into the collection. Below is a demonstration of the same − Input Input array: [Java, Python, Scala, Shell] Output After elements after converting the array to a list ... Read More

Find Maximum of Three Numbers in Java

karthikeya Boyini
Updated on 04-Nov-2024 18:42:13

30K+ Views

In this article, we will learn how to find the maximum among three numbers using an if-else statement in Java. The if-else construct allows us to evaluate conditions and execute different blocks of code based on whether the conditions are true or false. We will check the values of three numbers to determine the largest by using comparison operators and control flow statements. Problem StatementGiven three integer values, write a Java program to find the maximum among them using if-else statements. Input num1 = 15, num2 = -5, num3 = 7 Output 15 is the maximum number. Steps to ... Read More

Java NumberFormat getInstance Method

Samual Sam
Updated on 04-Nov-2024 18:41:47

630 Views

In this article, we will learn how to format numbers in Java using the NumberFormat class from the java.text package. The NumberFormat class provides methods for formatting numbers based on Locale settings, which is useful for creating internationalized Java applications. Using the NumberFormat.getInstance() method, we can format double, int, or float values in a Java program.  Problem StatementGiven a decimal value, we need to format the number using Java's NumberFormat class to round it according to the default Locale settings.Input double val = 1.9898798; Output Formatted Value: 1.99 ... Read More

Difference Between git push origin and git push origin master

Moksh Gupta
Updated on 04-Nov-2024 13:37:19

1K+ Views

If you ever use Git while working on a project, one of the routine tasks you will encounter is always pushing code to a remote repository. The two commands that many developers, including those who are new to the git environment, find difficult to disentangle include git push origin and git push origin master. Though they look similar, these commands have distinct functions and use cases.In this article, we will look at the distinctions between these commands, when they can be applied, and how not to upset your team of programmers. Let’s dive in!1. Understanding git push origingit push origin are ... Read More

Combine Multiple Git Commits into One

Moksh Gupta
Updated on 04-Nov-2024 13:15:48

512 Views

If you’re a Git developer, you’ve probably dealt with a noisy commit history. Adding multiple Git commits into one (a process called squashing) can help to organize your commit history. In this tutorial, I will show you how to combine Git commits into a single, nice, clean commit.Why Combine Git Commits?Combining or squashing multiple Git commits has several benefits:Cleaner History: It helps to keep a tidy project’s history with merging small, incremental changes into a single commit.Easier Collaboration: It simplifies code reviews by bringing all changes which go together, under the same commit.Better Readability: It makes it easier to track ... Read More

Make Git Forget About a Tracked File in .gitignore

Moksh Gupta
Updated on 04-Nov-2024 13:03:20

176 Views

If you’ve ever tried adding files to your Git repository (say, config files that you didn’t want tracked) only to have realized later that they shouldn’t have been added in the first place, you might have created your .gitignore file. But somehow, you’ll find that Git still does track them even when they’re intended to be added to .gitignore. This is annoying but fortunately Git has a way to go and forget those tracked files forever. In this article, I will present a step-by-step guide to work through this common Git problem.Why is Git Keeping Ignored Files?Anything that goes into ... Read More

Stop Tracking and Start Ignoring in Git

Moksh Gupta
Updated on 04-Nov-2024 12:35:38

230 Views

Git is an effective system for version control, but in some cases, there is information that is best left out of our version control trees entirely. They may be temp files, system files, or some confidential data that should not be committed. Read this article to learn how to untrack files that Git has been tracking and how not to let Git track new files in the future. In addition, we have explained in this article how you can use the git ignore feature to clean your work and avoid unnecessary files.Why Ignore Files in Git?Ignoring files in Git can ... Read More

Difference Between CouchDB and MySQL

Moksh Gupta
Updated on 04-Nov-2024 12:21:34

233 Views

When it comes to databases, often the choice of technology to be implemented is decisively important for the success of an application. In the context of an increasingly wide choice of options, knowing the distinctive features and benefits of one or another database affects the aspect of scalability, flexibility, and performance critically. In this article, we will explore quote CouchDB is and how it solves different problems than MySQL – two of the most commonly used database engines that work on entirely different paradigms for vastly different uses. What is CouchDB CouchDB is a free and document-based non-SQL database that ... Read More

Advertisements