Articles on Trending Technologies

Technical articles with clear explanations and examples

Remove all cancelled tasks from the timer's task queue in Java

George John
George John
Updated on 26-Jun-2020 426 Views

One of the methods of the Timer class is the int purge() method. The purge() method removes all the canceled tasks from the timer’s task queue. Invoking this method does not affect the behavior of the timer, rather it eliminates references to the canceled tasks from the queue. The purge() method came into existence since JDK 1.5.The purge() method acts as a medium for space-time tradeoff where it trades time for space. More specifically, the time complexity of the method is proportional to n + c log n, where n is the number of tasks in the queue and c ...

Read More

Python program to check if a string is palindrome or not

karthikeya Boyini
karthikeya Boyini
Updated on 26-Jun-2020 4K+ Views

Given a string, our task is to check weather this string is palindrome or not.AlgorithmStep1: Enter string as an input. Step2: Using string slicing we reverse the string and compare it back to the original string. Step3: Then display the result.Example codemy_string=input("Enter string:") if(my_string==my_string[::-1]):    print("The string is a palindrome") else:    print("The string isn't a palindrome")OutputEnter string:madam The string is a palindrome Enter string:python The string isn't a palindrome

Read More

Deque in Python

Samual Sam
Samual Sam
Updated on 26-Jun-2020 8K+ Views

The Deque is basically a generalization of stack and queue structure, where it is initialized from left to right. It uses the list object to create a deque.It provides O(1) time complexity for popping and appending.The Dequeis a standard library class, which is located in the collections module.To use it at first we need to import it the collections standard library module.import collectionsIn this section we will see some functions of the Deque classThe Appending functions on DequeThere are two different types of append. The append() method is used to add elements at the right end of the queue, and ...

Read More

How to use OFFSET in Android sqlite?

Smita Kapse
Smita Kapse
Updated on 26-Jun-2020 665 Views

Before getting into example, we should know what sqlite data base in android is. SQLite is an open source SQL database that stores data to a text file on a device. Android comes in with built in SQLite database implementation. SQLite supports all the relational database features. In order to access this database, you don't need to establish any kind of connections for it like JDBC, ODBC etc.This example demonstrate about How to use OFFSET in Android sqliteStep 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create ...

Read More

Does JVM creates object of Main class in Java?

Ankith Reddy
Ankith Reddy
Updated on 26-Jun-2020 608 Views

As we know that Java needs main() method to be static in the public class to make it executable. The prime reason for this requirement is to make JVM enable to call the main() method without creating an object. That simply means that JVM does not create the object of the Main class which contains the main() method. To justify the same, we can make the Main class containing the main method as abstract and program still runs.Following example showcases the same. Here we have made the main class abstract.Exampleabstract public class Tester {    public static void main(String args[]) ...

Read More

How Java objects are stored in memory?

Arjun Thakur
Arjun Thakur
Updated on 26-Jun-2020 4K+ Views

A stack and a heap are used for memory allocation in Java. However, the stack is used for primitive data types, temporary variables, object addresses etc. The heap is used for storing objects in memory.Stacks and heaps in Java are explained in more detail as follows −Stack in JavaStacks are used to store temporary variables, primitive data types etc. A block in the stack exists for a variable only as long as the variable exists. After that, the block data is erased and it can be used for storing another variable.

Read More

What is a nebula and how is it formed?

Shanmukh Pasumarthy
Shanmukh Pasumarthy
Updated on 26-Jun-2020 741 Views

A nebula is an interstellar cloud of dust made of hydrogen, helium and other ionized gasses. Initially, it was a name given for any diffuse cosmic object, including galaxies past the Milky Way.Most nebulae are of the tremendous size, even a great many light years in diameter. The nebula that is scarcely noticeable to the human eye from Earth would seem bigger, yet not brighter, when near it. The Orion Nebula, the brightest cloud in the sky that involves an area double the diameter of the full Moon, can be seen with the exposed eye yet was missed by early ...

Read More

How to create your own helper class in Java?

Arjun Thakur
Arjun Thakur
Updated on 26-Jun-2020 4K+ Views

A helper class serve the following purposes.Provides common methods which are required by multiple classes in the project.Helper methods are generally public and static so that these can be invoked independently.Each methods of a helper class should work independent of other methods of same class.Following example showcases one such helper class.Examplepublic class Tester {    public static void main(String[] args) {       int a = 37;       int b = 39;       System.out.println(a + " is prime: " + Helper.isPrime(a));       System.out.println(b + " is prime: " + Helper.isPrime(b));    } } ...

Read More

Read and write tar archive files using Python (tarfile)

George John
George John
Updated on 26-Jun-2020 3K+ Views

The ‘tar’ utility was originally introduced for UNIX operating system. Its purpose is to collect multiple files in a single archive file often called tarball which makes it easy to distribute the files. Functions in tarfile module of Python’s standard library help in creating tar archives and extracting from the tarball as required. The archives can be constructed with gzip, bz2 and lzma compressions or without any compression at all.Main function defined in this module is main() using which writing to tar file or reading from it is accomplished.Open()This function returns a TarFile object corresponding to file name which is ...

Read More

What are the consumer rights and responsibilities?

Shanmukh Pasumarthy
Shanmukh Pasumarthy
Updated on 26-Jun-2020 340 Views

Shopper rights are presently a vital part of our lives. They have been well framed and tremendously discussed. We have all made utilization of them eventually in our day to day activities. Market assets and impacts are developing every day and so is the familiarity with consumer rights. These rights are well characterized and there are agencies like the consumer courts and government offices that work towards shielding them.Keeping in mind the goal to protect consumer interest, six rights were put forth by consumer rights activists of the West, which are:Right to InformationRight to SafetyRight to ChoiceRight to be HeardThe ...

Read More
Showing 53161–53170 of 61,297 articles
Advertisements