Don't wanna be here? Send us removal request.
Text
Java program to detect a cycle in a singly LinkedList
Java program to detect a cycle in a singly LinkedList
In this article, we will learn how to detect a cycle or loop in a Linkedlist. We will be using Floyd’s cycle finding algorithm also know an the “tortoise and the hare algorithm” Floyd’s Tortoise and Hare algorithm Floyd’s cycle-finding algorithm is a pointer algorithm that uses two pointers, which move through the sequence at different speeds. If the two pointers refer to the same node at some…
View On WordPress
0 notes
Text
How to get current date time (today's date) in Java
How to get current date time (today’s date) in Java
In this article, we will discuss how to get current date and time using the legacy Date and Calendar apis alongwith the Java 8 LocalDate, LocalTime, LocalDateTime and ZonedDateTime apis. Current date using java.util.Date instance Date d1 = new Date(); System.out.println(d1); // Tue Mar 06 22:50:37 EST 2018 If you are looking to format the current date in a specific format, use the…
View On WordPress
#current date time in java#current date using calendar#current date using localdate#current date using localdatetime#current datetime in java#current time in java#How to get Current Date and Time in Java with Example#java current date#java current date example#java current date time#java current date Using java.util.Date instance#java now#java today#java today&039;s date
0 notes
Text
Spring Boot - CRUD operations using JPA
Spring Boot – CRUD operations using JPA
In this article, we will use the JPA (Java Persistence API) with Spring Boot for insert, update, delete and read operations. We are using in-memory H2 database, but the same can be changed for any other relational database. Project Structure We can use Spring Tool Suite(STS) to create a Spring starter project and choose the h2 and jpa dependencies. We can also use Spring Initializr for the same…
View On WordPress
#Data Access Using JPA with Spring Boot#jpa spring boot#Spring Boot CRUD operations using JPA#spring boot jpa#spring boot jpa crud operations
0 notes
Text
Java program to remove duplicate characters from a String
Java program to remove duplicate characters from a String
In this article, we will discuss how to remove duplicate characters from a String. Here is the expected output for some given inputs : Input : topjavatutorial Output : topjavuril Input : hello Output : helo The below program that loops through each character of the String checking if it has already been encountered and ignoring it if the condition is true. package com.topjavatutorial; public…
View On WordPress
#delete duplicate characters in a string#How to remove duplicate characters from a string in java#java - function to remove duplicate characters in a string#Java - Remove duplicates from a string#java LinkedHashSet#java remove duplicate characters#java remove duplicate characters preserving order#java remove duplicate chars from String#java remove duplicates#Remove all duplicates from a given string#Remove duplicate values from a string in java#remove duplicates from String in java#Removing duplicates from a String in Java
0 notes
Text
Java program to find Longest Common Subsequence
Java program to find Longest Common Subsequence
Longest Common Subsequence Problem This problem looks to find the longest common subsequence between two strings. This is not same as finding longest common substring between two strings. While substrings occupy consecutive positions, subsequences can be in random order and need not take consecutive positions. Recursive solution for Longest Common Subsequence package com.topjavatutorial; public…
View On WordPress
0 notes
Text
10+ Java Letter / Character Pattern Programs
10+ Java Letter / Character Pattern Programs
In Java, we can use for loop, while loop or do-while loops to print different number, alphabet or star patterns programs. Here are some examples for character or letter pattern programs. For other patterns, please refer the links at the end of the post. Character Pattern Program 1: A BC DEF GHIJ KLMNO class CharPattern1 { public static void main(String[] args) { char ch = 'A'; for (int i = 1; i…
View On WordPress
#alphabet pattern printing in java#alphabet patterns in java#character pattern programs#character patterns in java#diamond letter program in java#difficult pattern programs in java#how to print character in pattern java#java Character Pattern Programs#Java letter pattern programs#java letter pattern programs examples#java patterns using for loop#java program for patterns#java program to print the following pattern#java programs for patterns#java triangle pattern programs#letter pattern in java#letter pattern programs#letter pattern programs in java#letter pattern programs in java using for loop#letter patterns in java#letter pattrns in java#letter program patten in java#pattern java program#pattern printing in java#pattern program in java#pattern program using for loop in java#pattern programs in java#pattern programs in java using for loop#print patterns in java#printing java character patterns
0 notes
Text
java regex pattern compile unclosed character class regex
In this article, we try to address a frequently encountered error with regular expression in java : PatternSyntaxException: Unclosed character class The following example demonstrates this : import java.util.regex.Matcher; import java.util.regex.Pattern; public class Hello { public static void main(String[] args) { String regex = "[a-zA-Z\\]*$"; String value = "hello"; boolean match =…
View On WordPress
0 notes
Text
Spring Boot Microservice - How to fix "BindException: Address already in use: bind" error
Spring Boot Microservice – How to fix “BindException: Address already in use: bind” error
If you are getting the following error while starting your spring-boot application, this means the 8080 port is being used by another application. You can stop the other application, or follow the approach mentioned below. java.net.BindException: Address already in use: bind at sun.nio.ch.Net.bind0(Native Method) at sun.nio.ch.Net.bind(Net.java:433) at sun.nio.ch.Net.bind(Net.java:425) at…
View On WordPress
0 notes
Text
Android Studio - Gradle project refresh/sync failed : connection timed out
Android Studio – Gradle project refresh/sync failed : connection timed out
This article tries to address following issues while starting Android Studio Gradle sync failed: Connection timed out Gradle project refresh failed : connection timed out If you are getting this error while starting Android studio, it will be mostly because its not able to connect to Internet. Check if you are able to connect to internet from Android Studio. For this, go to File -> Settings…
View On WordPress
#Android Studio - Gradle project refresh/sync failed#gradle project refresh failed in android studio#gradle project sync failed in android studio
0 notes
Text
Spring Boot : Adding basic security to microservices
Spring Boot : Adding basic security to microservices
In this article, we will add basic authentication to a previous Spring application we created in this post : Spring Boot Hello World Adding maven dependency Add the following dependency to the pom.xml : org.springframework.boot spring-boot-starter-security This will add the following jars to the maven : spring-security-config-X.X.X.RELEASE.jar spring-security-core-X.X.X.RELEASE.jar…
View On WordPress
#basic security with spring boot service#example code for spring boot security#securing spring microservice#spring boot security
0 notes
Text
How to integrate Swagger 2 with Spring Boot
How to integrate Swagger 2 with Spring Boot
In this article, we will see how to integrate Swagger 2 with Spring Boot to generate a simple api documentation. What is Swagger ? Swagger is set of open source tools that helps with creating documentation for your REST services. Lets start with creating a Spring Tool Web application. You can refer the following article for the same. Spring Boot Hello World Web Application Adding Swagger 2…
View On WordPress
0 notes
Text
How to fix “Source folder is not a Java project” error in eclipse
How to fix “Source folder is not a Java project” error in eclipse
If you are creating a maven web project in eclipse and get a “Source folder is not a Java project” error, here is how to fix that : To fix this, right click on your project and select Properties -> Project Facet Click on “convert to faceted form” Select “Java” and click on “Apply and Close” and you should see the java source folder package structure in the project.
View On WordPress
0 notes
Text
How to configure proxy in Eclipse
How to configure proxy in Eclipse
If you are behind a proxy and want Eclipse to connect to internet for some plugins like STS(Spring Tool Suite), follow the following steps : In Eclipse menu bar, go to Window -> Preference. Select General -> Network Preferences. Switch the provider to “manual” and update the HTTP and HTTPS entries for the proxy host and port. Provide user id & pwd if you need to authenticate to use the proxy. You…
View On WordPress
0 notes
Text
Handlebars.js - How to escape or display special html characters
Handlebars.js – How to escape or display special html characters
Handlebars by default escapes special characters. So, if you trying to print special characters like ™ or ® etc, they will be escaped and the corresponding html codes will be printed. For example , Handlebars js Output : Note that, the above example doesnot print the ™ symbol. Rather, it prints the html characters as is. However, if you don’t want Handlebars to escape a value, use the…
View On WordPress
#Handlebars HTML entity decode#handlebars Insert html in a handlebar template without escaping#How to escape encoding html tags in handlebars
0 notes
Text
Handlebars.js - Partials
Handlebars.js – Partials
Handlebars allows code reuse using Partials. A Partial is a common template that can be included in another template. To create and register a partial, the method Handlebars.registerPartial() can be used as show below : Handlebars.registerPartial("messagePartial","Employee : {{name}}, Age : {{age}}" ); The first parameter to registerPartial() is the name of the partial template and second…
View On WordPress
0 notes
Text
Handlebars.js - Unless helper
Handlebars.js – Unless helper
The unless helper in handlebars works as “if not”. So, the block under the unless helper will be rendered if the expression passed is false. For example, the following code will display the block of text “No name element present” only if name is not available in the context. {{#unless name}} No name element present {{/unless}} Here is the complete example : Handlebars js In the above data passed,…
View On WordPress
0 notes
Text
Handlebars.js - Creating Custom Helpers
Handlebars.js – Creating Custom Helpers
Handlebars Helpers Helpers in Handlebars.js are reusable functions that can be added to data to change its behavior in some way. Handlebars provides several built-in helpers such as if, each, unless etc. (For built-in helper, refer http://handlebarsjs.com/builtin_helpers.html) Creating custom Handlebars Helpers We can create our own helper functions in Handlebars using the registerHelper()…
View On WordPress
#create custom helper in handlebars#creating helper functions in handlebars#Handlebars custom helpers
0 notes