If you’re looking to append a bunch of strings together separated by a certain character or characters, then there’s an easy way in Golang to do exactly that.
Let’s say you have a list of food items: pizza, pasta, sushi, pho, and tikka masala.
In Golang, that can be represented like this:
Note that we declared a slice there.
Golang’s blog describes slices as follows:
Go’s slice type provides a convenient and efficient means of working with sequences of typed data. Slices are analogous to arrays in other languages, but have some unusual properties.
Going further, a slice is…
If you work with Java’s HashMap data structure often — and you probably should be (hello, O(1) time complexity for data adds and retrievals) — then you’ll sometimes want to take advantage of the getOrDefault()
method.
Before we even get to the code itself and to some examples, I think it’d be helpful to understand in plain English what the function is really achieving.
Basically, you’re trying to get a certain value in the map by specifying its key (and remember that HashMap
is a mapping of key(s) to value(s). …
This is one of the most useful keyboard shortcuts I can think of when it comes to working with IntelliJ IDEA: find in files.
What that basically means is that if you’re looking for a particular word or keyword or string or substring or number in all of your project files, you can simply use the find in files feature built into the Integrated Development Environment (IDE) and then get a list of all files that match your input as well as where exactly in the code it occurs.
To put it more concisely (and colloquially), it’s awesome.
No more…
When you think of immutability in Java, there are a core set of concepts that should come to mind.
In this article, I’ll enumerate some of the major points, and hopefully you’ll have a better idea of what it takes to be immutable in Java.
Immutability in Java at a high level essentially means what it does in English. In other words, something that is immutable in Java can’t change.
In Java, that means that the content or state of an immutable object simply can’t be changed. The language won’t allow it.
The reason for this is because in Java…
If you’re looking for a basic look into what young generation, old generation, and permanent generation means in terms of Java, then you’re in the right place.
These terms seem more fit for people than for software concepts, but read on and hopefully they’ll make more sense.
Essentially, the scope of what we’re talking about here is Java garbage collection.
In programming languages like C, developers have to take close care of memory by allocating and deallocating it accordingly.
Java, on the other hand, has its own automatic garbage collection with the idea that most developers don’t have to worry…
Awesome, love to hear it! Definitely is satisfying to me too for PRs. Thanks for your comment.
If you’re here, then you probably received the following error when you try to access a Google AdSense page:
We apologize for the inconvenience, but we are unable to process your request at this time. Our engineers have been notified of this problem and will work to resolve it.
In screenshot form, the error is the only thing you see on the page:
Spring Boot is awesome for many reasons, and one of them is the ease of setting up external configuration so that you can run the same application code in different environments or update variables at any time without going in and having to change the code itself.
This article will go over how to achieve this in your Java application with Spring Boot using the annotations @Component
and @ConfigurationProperties
.
First, you’ll have to create a Java class that will be a Spring Boot bean by way of the @Component
annotation.
In it, the variables will be the ones that you…
So you want to programmatically send emails with Amazon Simple Email Service, or SES for short.
This article concerns how to do exactly that in Java.
According to Amazon, “Amazon Simple Email Service (SES) is a cost-effective, flexible, and scalable email service that enables developers to send mail from within any application. You can configure Amazon SES quickly to support several email use cases, including transactional, marketing, or mass email communications. Amazon SES’s flexible IP deployment and email authentication options help drive higher deliverability and protect sender reputation, while sending analytics measure the impact of each email. …
If you need to alphabetically sort a String
in Java, then you’ll want to read on and memorize this order of operations.
First of all, there is no native function in Java to just take a String
and then sort it.
String
into an array of characters (char
)String
using the array of charactersSo to reiterate, first we are defining a character array and then initializing it with our input string, str
, that has the toCharArray()
function applied to…