• 13 December

    Java Random nextInt

    In this tutorial, we will see Java Random nextInt method.It is used to generate random integer. There are two overloaded versions for Random nextInt method. nextInt() Syntax [crayon-664489a8a0190924436014/] Here random is object of the java.util.Random class. Return returns random integer. Example Let’s see a very simple example: [crayon-664489a8a019a821876996/] Output: Random Integer: 1326186546 Random Integer: 203489674 […]

  • 13 December

    Java – generate random String

    In this tutorial, we will see how to generate random String in java. There are many ways to generate random String.Let’s explore some of ways to generate random String. Using simple java code with Random You can use SecureRandom class to generate random String for you. Let’s understand with the help of example. [crayon-664489a8a0d73764821394/] Output: […]

  • 13 December

    Random number generator in java

    In this tutorial, we will see about random number generators.You might have requirement where you want to generate random numbers to perform some operation. For example: Let’s say you are creating a game which uses dice for each player’s turn. You can put logic to generate random number whenever the player uses dice. There are […]

  • 09 December

    Python String to datetime

    In this tutorial, we will see how to convert String to datetime object. Let’s say, you got String as input and you want to convert it datetime object to extract various details from it. Using strptime Using parser Using strptime method You can simply use strptime to convert String to datetime. Let’s understand with the help of […]

  • 09 December

    Python datetime to String

    In this tutorial, we will see how to convert datetime to String object. Let’s say, you have datetime as input and you want to convert it string to display it. Using strftime Using format Using strptime method You can simply use strptime to convert datetime to String. Let’s understand with the help of example. [crayon-664489a8a2256004554985/] Output: datetime […]

  • 08 December

    Python Convert list to set

    In this tutorial, we will see how to convert list to set. You can use python set() function to convert list to set.It is simplest way to convert list to set. As Set does not allow duplicates, when you convert list to set, all duplicates will be removed in the set. Let’s understand with the […]

  • 08 December

    convert set to list Python

    In this tutorial, we will see how to convert set to list in python. You can use python list() function to convert set to list.It is simplest way to convert set to list. Let’s understand with the help of example. [crayon-664489a8a2f0c350619806/] Output: set of Fruits: {‘Apple’, ‘Banana’, ‘Orange’} listOfFruits: [‘Apple’, ‘Banana’, ‘Orange’] set of scales: […]

  • 08 December

    How to create an empty list in python

    In this post, we will see how to create an empty list in python. There are two ways to create an empty list in Python. Using [ ] Using list() function. Let’s see this with the help of example. [crayon-664489a8a34ba594877714/] Output: List 1: [1, 2] List 2: [1, 2] Which is faster: [ ] or […]

  • 08 December

    Python tuple index()

    In this post, we will see about Python tuple’s index method.Python tuple’s index method is used to find index of element in the tuple Python tuple count syntax [crayon-664489a8a3c07371250455/] tuple1 is object of the tuple and element is the object which you want to get index. Python tuple count example Python tuple index method is […]