How to compare strings in Java?
String comparison in Java In Java, string comparison is used to compare two string values for equality or inequality. There are two main ways to compare strings in Java: using …
Read Morelearn to code by examples
String comparison in Java In Java, string comparison is used to compare two string values for equality or inequality. There are two main ways to compare strings in Java: using …
Read MoreSuppose you have the string ‘qwe’ and you need to repeat string ‘n’ times. Here’s how to do it with StringBuilder: Using StringBuilder and loop
1 2 3 4 5 6 7 8 |
int n = 3; String in = "qwe"; StringBuilder b = new StringBuilder(n * in.length()); for (int i = 0; i < n; i += 1) { b.append(in); } String newString = b.toString(); |
Last time, we set up a job checkstyle check locally. But for this test to be truly meaningful and to benefit the team, it is better to integrate this action …
Read MoreContinuous integration is one of the key parts of the modern software development process. Today we will set up the integration of the popular jenkins automation server with the private …
Read MoreFor the tests in your project to work, certain settings are necessary. Here are some guidelines for avoiding basic mistakes.
Read MoreSometimes inside corporate networks you may not have direct access to the Internet, but only through a proxy. In this article, we will look at how to use maven through …
Read MoreImagine that you have implemented your java jar library and you need to connect it. Here are some examples of how to do it.
Read MoreSince Java 5 you can use Arrays.toString(arr) or Arrays.deepToString(arr) for arrays within arrays. Note that the Object[] version calls .toString() on each object in the array. The output is even …
Read MoreGoogle GSON library Let’s assume you have a class Book with just a title.
1 2 3 4 5 6 7 |
private class Book { public String title; public Book(String title) { this.title = title; } } |
Create maven project and add dependencies.
1 2 3 4 5 |
<dependency> <groupId>com.google.code.gson</groupId> <artifactId>gson</artifactId> <version>2.8.5</version> </dependency> |
Then write this code to transform JSON into class: …
Read MoreI decided to collect code style examples from the well-known company in the java community. There are both direct links to setting up the checkstyle and examples of setting the …
Read More