Verification in the world of digital hardware design is a crucial step for ensuring correctness and reliability of hardware components prior to fabrication. Traditional methods of verification usually rely on hardware description languages (HDLs), like Verilog or VHDL, together with contracted verification languages and schemes. But these approaches are cumbersome and kill productivity. Here comes Cocotb, a novel approach combining the power of Python for a radically new way of writing an HW verifier. What is Cocotb? Cocotb (COroutine based COsimulation TestBench) is a free open source framework that allows to write testbenches in python to verify hardware design described ... Read More
In this article, we will learn how to use the contains() method in Java's HashSet class to check whether specific elements are present in a set. We'll create a HashSet, add some elements to it, and verify the existence of given elements using the contains() method. Problem Statement Write a Java program to check if a specific element exists in a HashSet using the contains() method. Below is the demostration of the same − Input Elements in set = [33, 66, 67, 54, 88, 90, 30, 79] Output Elements in set = [33, 66, 67, 54, 88, 90, 30, 79] ... Read More
In this article, we will understand how to multiply two matrices using multi-dimensional arrays in Java. The matrix has a row and column arrangement of its elements. A matrix with m rows and n columns can be called as m × n matrix. Individual entries in the matrix are called elements and can be represented by a[i][j] which suggests that the element a is present in the ith row and jth column. Problem Statement Write a program in Java to multiply two matrices using multi-dimensional arrays. Below is a demonstration of the same − Input First matrix: 2 3 4 ... Read More
In this article, we will learn to write a program for shell sort using Java. In the program, we’ll apply this technique to sort an array and observe how the algorithm optimizes the sorting process by reducing the interval between elements. Shell sort Shell sort is a sorting technique that is similar to insertion sort, wherein elements are sorted which are at far ends (either end) of the array. This way, the interval size between the next and the second to last element reduces. This happens for all the elements in the array until the interval distance is reduced to ... Read More
In this article, we will learn to set a JTextArea in Java to wrap text by word, ensuring that the words in the text fit neatly within the display area rather than breaking in the middle. We will create a simple GUI application using JTextArea and configure it to wrap text by word, so the content is more readable within the bounds of the text area. Steps to set JTextArea to wrap by word Following are the steps to set JTextArea to wrap by word − Import the required classes from javax.swing and java.awt for GUI ... Read More
In this article, we will learn how to change a Java Stream into a typed array in Java. By using the toArray() method with a constructor reference, we can ensure that the array has the right type. Problem StatementGiven a Stream of strings, write a Java program to convert it into a typed array and display the elements.Input Stream.of("Bing Bang Theory", "Vampire Diaries", "Game of Thrones", "Homecoming")Output Array...Bing Bang TheoryVampire DiariesGame of ThronesHomecoming Steps to convert the stream to a typed array The following are the steps to covert the stream to a typed array − ... Read More
In this article, we will convert a HashMap to a TreeMap in Java. A HashMap is used for storing data as key-value pairs, but it doesn’t keep the keys in any particular order. A TreeMap sorts the keys in ascending order. By converting a HashMap to a TreeMap, we can ensure that the keys are stored in a sorted way. Problem StatementGiven a HashMap filled with key-value pairs, we need to convert it into a TreeMap so that the entries are sorted by the keys.Input ("1", "A"), ("2", "B"), ("3", "C"), ("4", "D"), ("5", "E"), ("6", "F"), ("7", ... Read More
In this article, we will learn how to check if a String is empty in Java. The isEmpty() method is used to check whether a given string does not contain characters. Problem StatementGiven a string, write a Java program to determine if the string is empty.Input String str = ""Output String is empty: true Steps to check if a string is emptyThe following are the steps to check if a string is empty − Create a string. Use the isEmpty() method to check whether the string has no characters. ... Read More
In this article, we will learn how to create a Duration object in Java based on different time units like days, hours, milliseconds, and minutes, and then convert them into seconds. The Duration class in Java is part of the java.time package and is used to represent a duration of time in a standardized way. Problem StatementGiven time durations in days, hours, milliseconds, and minutes, write a Java program to create Duration objects from these values and calculate how many seconds they represent.Input Duration in days = 10Duration in hours = 10Duration in milliseconds = 10Duration in minutes = ... Read More
In this article, we will learn to use Java to make a file read-only and check if it can still be written. A file can be set to read-only by using the method java.io.File.setReadOnly(). This method requires no parameters and returns true if the file is set to read-only and false otherwise. The method java.io.File.canWrite() is used to check whether the file can be written in Java and if not, then the file is confirmed to be read-only. Problem StatementThe task is to write a Java program that makes the file read-only and then checks whether the file can still ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP