Java @ Desk

Java @ Desk

Breaking

Thursday, January 2, 2025

How to capitalize first letter of each word in a String in Python

3:10 AM 0

Wednesday, January 1, 2025

How to substring a string in Python

5:23 AM 0
Substring a string in Python is done using the below syntax - str = 'OriginalString'; substring_start = str[:8] print("Substring first 8 characters - " + substring_start) substring_end = str[8:] print("Substring last 8 characters - " + substring_end) Output - Substring first 8 characters - Original Substring last 8 characters - String ...

Thursday, April 21, 2022

Python remove leading and trailing white space from a String

7:21 AM 0
Python remove leading and trailing white space from a String Python have 3 functions to remove the trimmed space, remove leading whitespace and remove trailing whitespace. strip(): Removes leading and trailing whitespace. rstrip(): Removes trailing whitespace. lstrip(): Removes leading whitespace. string = ' Python Trim String ' print('Original String...

Monday, December 14, 2020

AtomicInteger and volatile in Multithreading Java

12:42 AM 0
AtomicInteger and volatile in Multithreading Java In our previous post, we learnt about the volatile keyword in Java. But volatile keyword is not sufficient to guarantee atomicity. Volatility just guarantees the visibility of the variable and NOT atomicity, whereas Synchronization (locking) guarantees both visibility and atomicity. But Synchronization affects...

Friday, December 11, 2020

Stream Intermediate vs Terminal Operation in Java 8

11:14 PM 0
Stream Intermediate vs Terminal Operation in Java 8 In Java 8, Stream is used to perform operations in pipeline to either get another Stream or Collection or Object. Stream operations are performed on objects that are returning Stream and not on any other type. The Stream operation that returns another Stream is an Intermediary Operation. Hence these can be...

Sunday, December 6, 2020

How to use Streams in Map in Java 8

6:01 AM 0
How to use Streams in Map in Java 8 Map, unlike, other Collection types is in a Key/Value Format where the Keys are unique in a Map. Using Map.Entry, we can fetch the keySet() as well as entrySet(). Stream cannot be applied directly to a Map since Stream is done on the Collection of Objects. So it is applied to a keySet() or a entrySet() or values() that return...

Tuesday, February 25, 2020

How to get sum of Integer or Double field from a List of Pojo Java class

6:52 AM 0
How to get sum of Integer or Double field from a List of Pojo Java class This post will demonstrate how to get sum of any particular field, for example, consider a List of Person class with property noOfMangoesEaten which represents how many mangoes an individual has consumed. Using Java 8, we need to find how many mangoes in total have been consumed by all...

Friday, January 25, 2019

Spring Validator Framework In Java

11:57 PM 0
Spring Validator Framework In Java Spring Validator Framework validates the input Java class properties. Validator class must implement org.springframework.validation.Validator and define the validator rules in the overridden method - public void validate(Object o, Errors errors) This method contains the validation rules. For example, for a Person class validation...
Page 1 of 4612345...46Next �Last