Author: Arpit Mandliya
- 03 June
How to check if String has all unique characters in java
Learn about how to check if String has all unique characters in java
- 30 May
Java ArrayList indexOf example
ArrayList‘s indexOf method is used to find out first index of object in arraylist. indexOf method takes object as argument and returns first occurrence of specified element. Methods: public int indexOf(Object o) returns index of first occurrence of element in the ArrayList. indexOf method return -1 if object is not present in the ArrayList ArrayList […]
- 24 May
Variable arguments or varargs methods in java
Java variable arguments was introduced in java 5 and it allows methods to take as many number of arguments you want. Syntax: We use three dots (…) also known as ellipsis to define variable arguments. [crayon-678283a267715249543440/] There are some points which you need to keep in mind while using varargs methods: You can have only […]
- 24 May
Java String compareTo example
String’s compareTo method compares two String lexicographically. Both String get converted to unicode value and then compares. If you call str1.compareTo(str2) then if it returns positive number : str1 is greater than str2 0: str1 is equal to str2 negative number : str1 is smaller than str2 Java String compareTo example [crayon-678283a2677e6886434098/] When you run […]
- 24 May
How to convert String to Byte array in java
Sometimes, we need to convert String to byte array. We can use getBytes() method of String to do it, Method syntax: [crayon-678283a26789b288631061/] String getBytes Example: [crayon-678283a26789e104071825/] When you run above program, you will get below output: [crayon-678283a26789f672878164/] There is one more overloaded method for getBytes Method syntax: [crayon-678283a2678a0021256678/] It encodes String to specified charset format. […]
- 23 May
log4j xml configuration example
Logging is essential part of programming. It helps developer to track code workflow and fix bugs efficiently. If we get any issue in the code, we check logs for that workflow or functionality. Log4j is fast , reliable logging framework and can be easily integrated with the code. It is possible to enable logging at […]
- 22 May
Difference between PATH and CLASSPATH in java
In this post , we will see differences between PATH and CLASSPATH in java. Let me provide simple definition about PATH and CLASSPATH. PATH : This is environment variable which operating system uses to locate executable such as javac, java, javah,jar etc. For example: bin directory of jdk has all the executable such as javac,java […]
- 20 May
jQuery Keypress enter example
In this post, we will see how to detect if enter key is pressed or not in jQuery. To capture enter keypress, we will bind dom element with keypress event and if ascii value is 13, then enter key is pressed. So basically code will look something like this. [crayon-678283a267bdd291768002/] If you want to catch […]
- 19 May
Java transient keyword with example
Transient variable is the variable whose value is not serialized during serialization. You will get default value for these variable when you deserialize it. Lets say you have Country class and you don’t want to Serialize population attribute as it will change with time, so you can declare population attribute as transient and it won’t […]