Create a Login Form in Java

Alshifa Hasnain
Updated on 16-Apr-2025 18:54:02

35K+ Views

We can develop a login form in Java using Java Swing technology. In this example, we can create two labels username and password, two text fields for the user to enter valid credentials,  and finally, one submit button. Once the user is able to enter the valid credentials in the two text fields, we can able to see Hello admin in the login form. Setting Up the Project We’ll use Java Swing, a GUI toolkit for building desktop applications. Required Libraries are: javax.swing.* (for Swing components) java.awt.* (for layout management) ... Read More

Change Order of public static void main in Java

Alshifa Hasnain
Updated on 16-Apr-2025 18:53:41

4K+ Views

Yes, we can change the order of public static void main() to static public void main() in Java, the compiler doesn't throw any compile-time error or runtime error. In Java, we can declare access modifiers in any order, the method name comes last, the return type comes second to last and then after it's our choice. But it's recommended to put access modifier (public, private and protected) at the forefront as per Java coding standards. Java Method Modifiers and Their Order Java allows you to place method modifiers (the keyword "public, " "static, " "final, " etc.) in various orders. The Java ... Read More

Convert Hex String to Int in Python

Yaswanth Varma
Updated on 16-Apr-2025 17:40:11

48K+ Views

A Hexadecimal is the base-16 number system that uses the digits from the '0 to 9' and letters from 'A to F'. It is commonly used in the computers to represent the binary data in the readable format. In this article we are going to learn about converting hex string into int. For example, if we receive the input as a hex string("12xf2") and need to convert it into a integer. For achieving this, Python provides the multiple methods let's explore them one by one. Using Python int() Function The Python int() function is used to convert ... Read More

Strip Punctuation from a String in Python

Yaswanth Varma
Updated on 16-Apr-2025 17:37:48

2K+ Views

When working with the text data in Python, We will come across the situations where we find the unwanted punctuation marks (like ., :?!) to remove. Removing punctuation helps to normalize text, making it easier to analyze. Python provides the several ways to achieve this, Let's dive into the article to learn ore about it. Using Python translate() Method The Python str.translate() method is a sequel for the maketrans() method in the string module. This method uses the translation table generated by the maketrans() and translate all characters based on the one-to-one mapping in the said table. ... Read More

Get Variable Name as String in Python

Yaswanth Varma
Updated on 16-Apr-2025 17:34:46

33K+ Views

In Python Variables are just the labels that are pointing to the values. They don't carry any built-in metadata about their names. That’s why there is no direct built-in method to get the variable name as a string. However, we can achieve this, by inspecting the environment such as using the globals(), locals(), or the inspect module. Let's dive into the article to learn more about getting a variable name as a string. Using Python globals() Function The Python globals() function is used to return a dictionary representing the current global symbol table. It provides ... Read More

Get Function Name as String in Python

Yaswanth Varma
Updated on 16-Apr-2025 17:28:57

18K+ Views

In Python, Functions are the first-class object, which means they can be passed around and manipulated like other data types (like integers, strings). This allows to inspect and retrieve the attribute of functions, including their names. In this article we are going to learn about getting the function names as string, To achieve we are going to use the built-in __name__ attribute. Let's dive into the article to learn more about it. Using Python Class __name__ Attribute The Python __name__ attribute is a special built-in variable that helps to determine the context in a which a Python ... Read More

Change the ID of an Immutable String in Python

Yaswanth Varma
Updated on 16-Apr-2025 17:26:18

1K+ Views

In Python,  strings are immutable, which means once the string is created, it cannot be changed. Because of this immutability, any operation that tries to modify the string results in creating a new string object with a different identity. Every object in Python has a unique identity, which can be accessed by using the built-in id() function. In this article, we are going to learn about changing the id of an immutable string in Python. We cannot directly change the ID of the immutable string, but by reassigning or modifying it, we can create a new string and ... Read More

Execute a String Containing Python Code in Python

Yaswanth Varma
Updated on 16-Apr-2025 17:06:56

19K+ Views

In Python, it is possible to execute the dynamically generated code or code stored as a string using the Python built-in functions like eval() and exec(). Both eval() and exec() functions should be used carefully, especially with untrusted input, as they execute any code, including the harmful instructions causing the security risk. In this article we will we go through several example of how to execute string containing the python code. Using Python eval() Function The Python eval() function is used to evaluate the string as a python expression and return ... Read More

Send Data Over Remote Method in Java

Maruthi Krishna
Updated on 16-Apr-2025 17:02:51

814 Views

RMI stands for Remote Method Invocation. It is a mechanism that allows an object residing/running in one system (JVM) to access/invoke an object running on another JVM. RMI is used to build distributed applications; it provides remote communication between Java programs. It is provided in the package java.rmi. To create an RMI Java application, you need to follow the steps given below - Step 1: Define the Remote Interface A remote interface provides the description of all the methods of a particular remote object. The client communicates with this remote interface. Therefore, you need to create an interface that extends ... Read More

Key Steps in Read/Write from/to a URL Connection in Java

Maruthi Krishna
Updated on 16-Apr-2025 16:29:17

513 Views

The URL class in the java.net package represents a web address or URL (Uniform Resource Locator), which points to a web resource such as a file, page, or directory in the World Wide Web (internet). The URL class provides various constructors, one of which accepts a String parameter (representing a URL) and constructs an object of the URL class. Reading From a URL You can read content from a URL using the openStream() method. This method opens a connection to the web address specified by the current URL object and gives you an InputStream object. The Java InputStream is an ... Read More

Advertisements