Posts

Showing posts from March, 2022

How to generate qr code or barcode in java

Image
In this tutorial, I'll show you how to create a QR code or barcode. How can you utilize or save the generated file?  In this tutorial, we will generate barcodes or QR codes using the zxing java package. zxing is an open-source, multi-format 1D/2D barcode image processing toolkit written in Java with portability to other programming languages. So, first and foremost, make a maven or Gradle project and follow this. Add these dependencies to your project. Maven Gradle <dependency> <groupId>com.google.zxing</groupId> <artifactId>core</artifactId> <version>3.4.1</version> </dependency> <dependency> <groupId>com.google.zxing</groupId> <artifactId>javase</artifactId> <version>3.4.1</version> </dependency> implementation 'com.google.zxing:core:3.4.1' implementation 'com.google.zxing:javase:3...

What is difference between length and length() in java

Image
T his is also a confusing topic of java and most beginners get confused about length and length(). I was also confused about this topic. After reading this article you will never get confused. So, We know that java is an Object Oriented Programming language we denote class as a template of objects and method is an action that an object is able to perform. You will see in java docs if we access any member of some class we use a method rather than a variable. Likewise,  length():- length() is a function of string class that is used to get the length of a string. And length:- length is variable for getting the length of an array. Look At the example:- Length() with string FindLength.java public class FindLength { public static void main(String[] args) { String str = "this is skx coding"; int strLength = str.length(); System.out.println("length of str: "+ strLen...

Everything you need to know about finding index of item in list with java

Image
In this article, we will discuss finding the index of the list. List<T> is an interface in java that provides many helpful methods for operating items of lists. The IndexOf() method returns the index of an item if the item found else it return -1. There are two methods we can use for finding index: indexOf(Object obj):- This method returns the first index of an item if it is present in the list. FindIndex.java import java.util.Arrays; import java.util.List; public class FindIndex { public static void main(String[] args) { List<String> list = Arrays.asList( "Are", "you", "programmer","?", "you", "are", "awesome!." ); String findMe = "you"; System.out.println("Index of "+ findMe +": " +list.lastIndexOf(findMe)); } } Ou...