Get the List of All Public Methods in Java

George John
Updated on 25-Jun-2020 14:05:34

6K+ Views

A list of all the public methods of a class or interface that is represented by an object are provided using the method java.lang.Class.getMethods(). The public methods include that are declared by the class or interface and also those that are inherited by the class or interface.Also, the getMethods() method returns a zero length array if the class or interface has no public methods or if a primitive type, array class or void is represented in the Class object.A program that demonstrates this is given as follows −Example Live Demoimport java.lang.reflect.Method; public class Main {    public static void main(String[] argv) ... Read More

CSS white-space Property

vanithasree
Updated on 25-Jun-2020 14:05:20

124 Views

Use the white-space property to work with white-space inside an element:ExampleLive Demo                    p.demo1 {             white-space: normal;          }          p.demo2 {             white-space: pre;          }                     Control white-space                This is demo text.          This is demo text.                      This is demo text.          This is demo text.          

Display the Package Name of a Class in Java

Chandu yadav
Updated on 25-Jun-2020 14:05:00

6K+ Views

The package for a class can be obtained using the java.lang.Class.getPackage() method with the help of the class loader of the class. If there is no package object created by the class loader of the class, then null is returned.A program that demonstrates this is given as follows −Example Live Demoimport java.util.Date; public class Main {    public static void main(String[] args) {       Date d = new Date();       Package p = d.getClass().getPackage();       String pName = p.getName();       System.out.println("The package name is: " + pName);    } }OutputThe package name is: ... Read More

Most Common POSIX System Calls in Python

Arjun Thakur
Updated on 25-Jun-2020 14:04:38

949 Views

The posix module is works on the UNIX environment. It provides the Operating system functionality.We should not import this module directly. We can use the os module. The os module is acts as a superset of the posix module on UNIX. On non-Unix system the posix is not available, but the os is available with some less functionality.To use the posix module, we should import it using.import posixThere are different methods and constants in the POSIX module.Constant posix.environThe environ is a dictionary object. It holds keys and values. The keys and values are of bytes type for UNIX. For example, ... Read More

Generate Random Long Type Numbers in Java

Arjun Thakur
Updated on 25-Jun-2020 14:04:27

5K+ Views

In order to generate Random long type numbers in Java, we use the nextLong() method of the java.util.Random class. This returns the next random long value from the random generator sequence.Declaration − The java.util.Random.nextLong() method is declared as follows −public long nextLong()Let us see a program to generate random long type numbers in Java −Example Live Demoimport java.util.Random; public class Example {    public static void main(String[] args) {       Random rd = new Random(); // creating Random object       System.out.println(rd.nextLong()); // displaying a random long value    } }Output-4787108556148621714Note - The output may vary on Online compilers.Read More

Access to the Password Database in Python

Ankith Reddy
Updated on 25-Jun-2020 14:04:13

594 Views

To access the password database, we should use the pwd module. Using this module, we can access users account and password database. The password database entries are like tuple like object.To use the pwd module, we should import it using.import pwdThe attributes of the password database are −IndexAttribute & Description0pw_nameThe Login Name or the username of the user1pw_passwdThe Encrypted password2pw_uidNumeric ID for the user3pw_gidNumeric ID for the user’s group4pw_gecosName of the user and comment field5pw_dirHome directory of the user6pw_shellUser’s Command interpreter.Note − Generally, the pw_passwd holds the encrypted passwords. But in the new systems, they use the shadow password system. ... Read More

Sort Words in Lexicographical Order in Java

karthikeya Boyini
Updated on 25-Jun-2020 14:03:52

2K+ Views

The words are sorted in lexicographical order or dictionary order. This means that the words are alphabetically ordered based on their component alphabets. An example of this is given as follows.The original order of the words is Tom Anne Sally John The lexicographical order of the words is Anne John Sally TomA program that demonstrates this is given as follows.Example Live Demopublic class Example {    public static void main(String[] args) {       String[] words = { "Peach", "Orange", "Mango", "Cherry", "Apple" };       int n = 5;       System.out.println("The original order of the words ... Read More

Access to the Group Database in Python

George John
Updated on 25-Jun-2020 14:03:37

311 Views

To access the UNIX group database, we should use the grp module. The shadow password database entries are like tuple like object.To use the grp module, we should import it using −import grpThe attributes of the grp database are −IndexAttribute & Description0gr_nameThe Name of the groups1gr_passwdThe Encrypted password for the group. (Generally empty)2gr_gidThe group id (Numeric)3gr_memA list of group usersIn the group object, the gid is an integer. The group name and the password are strings. The Member list is a list of strings.Some methods of this module are −Method grp.getgrgid(gid)This method will return group database entry from the given ... Read More

GetPackage Return for a Class in Unnamed Package in Java

George John
Updated on 25-Jun-2020 14:02:36

290 Views

The package for a class can be obtained using the java.lang.Class.getPackage() method with the help of the class loader of the class.The getPackage() method returns null for a class in unnamed package. A program that demonstrates this is given as follows −Example Live Democlass Class1 {    public class Main {       public static void main(String[] argv) throws Exception {       Class c = Class1.class;       System.out.println(c.getPackage());    } }OutputnullNow let us understand the above program.The getPackage() method is used to obtain the package for the class. However, the getPackage() method returns null for the ... Read More

Compression Compatible with Gzip in Python Zlib

George John
Updated on 25-Jun-2020 14:02:35

902 Views

The zlib module provides Python’s implementation of Zlib compression library (http://www.zlib.net) which is a part of GNU project.This article discusses important functions defined in zlib module.compress()This function is the primary interface to this module along with decompress() function. This function returns byte object by compressing the data given to it as parameter. The function has another parameter called level which controls the extent of compression. It an integer between 0 to 9. Lowest value 0 stands for no compression and 9 stands for best compression. Higher the level of compression, greater the length of compressed byte object.decompress()This function does the ... Read More

Advertisements