Author: Arpit Mandliya
15 MayInvoke constructor using Reflection in java
In this post, we will see how to invoke constructor using reflection in java. You can retrieve the constructors of the classes and instantiate object at run time using reflection. java.lang.reflect.Constructor is used to instantiate the objects. Instantiate Constructor with no parameters In case, you want to create object using no args constructor at runtime, […]
04 MayValidate password in java
In this post, we will see how to validate a password in java. Here are rules for password: Must have at least one numeric character Must have at least one lowercase character Must have at least one uppercase character Must have at least one special symbol among @#$% Password length should be between 8 and […]
04 MayJava regex for currency symbols
In this post, we will see about regex to find currency symbols in a text. You can use below regex to find currency symbols in any text. \\p{Sc} Each unicharacter belongs to certain category and you can search for it using /p. Sc is short code for current symbol, so using \p{Sc}, we are trying […]
04 MayPython Regex for alphanumeric characters
In this post, we will see regex which can be used to check alphanumeric characters. Let’s say you want to check user’s input and it should contain only characters from a-z, A-Zor 0-9. Here is the regex to check alphanumeric characters in python. ^[a-zA-Z0-9]*$ Here is the explaination of above regex. ^ : denotes start […]
04 MayPython concatenate string and int
This tutorial teaches how to concatenate string and int in Python In other languages such as Java, C++, etc, you can concatenate string and int using + operator, but you can not do the same in python. How to concatenate string and int in Python Let’s first try to use + operator to concatenate string […]
04 MayJava credit card validation – Luhn Algorithm in java
In this post, we will see about Luhn Algorithm in java Introduction Luhn algorithm, also known as modulus 10 or mod 10 algorithm, is a simple checksum process for validating various identification numbers such as credit card numbers, Canadian social securities numbers. This algorithm is designed to protect again mistyped or accidental error rather than […]
26 AprilJava Stream List to Map
In this post, we will see how to convert List to Map using Stream in java 8. Collectors’s toMap() can be used with stream to convert List to Map in java. Consider a class Named Movie which have 3 fields – id, name and genre [crayon-69304199473bf640747293/] Create a list of movies and convert with to […]
26 AprilJava Stream sorted example
In this post, we will see how to sort a list with Stream.sorted() method. Java 8 has introduced Stream.sort() method to sort list of elements conveniently. It helps us to write short and concise functional style code rather than boilerplate code. java.util.Stream has two overloaded versions of sorted() method. sorted(): Returns a stream having elements […]
26 AprilPython pretty print json
In this post, we will see how to pretty print JSON in Python. We can use the Python JSON module to pretty-print JSON data. We can use json’s dumps() method with indent parameter to pretty print json data. Python pretty print json string Let’s understand this with the help of example. [crayon-6930419947a9e314499292/] Output: [ { […]