Found 34494 Articles for Programming

How to rename multiple files recursively using Python?

Rajendra Dharmkar
Updated on 25-Jul-2023 09:36:59

3K+ Views

The act of renaming multiple files recursively in Python can be a useful task when it is required to change the names of multiple files within a directory and its subdirectories. If you need to replace certain characters, add prefixes or suffixes, or completely change the file names, Python has powerful tools to accomplish such operations. In this article, we explore a few different approaches to renaming multiple files recursively using Python. We consider some code examples, each demonstrating a unique method to achieve this task. So let us get started right away and learn how to rename multiple files ... Read More

What is the difference between /* */ and /** */ comments in Java?

vanithasree
Updated on 30-Jul-2019 22:30:20

561 Views

Multiline comments (/* */) are used to comment multiple lines in the source code. Example Live Demo public class CommentsExample { /* Following is the main method here, We create a variable named num. And, print its value * */ public static void main(String args[]) { //Declaring a variable named num int num = 1; ... Read More

How to rename directory using Python?

Rajendra Dharmkar
Updated on 25-Jul-2023 09:31:07

8K+ Views

There are times when you want to organize your files or update the directory names to better reflect their contents. In such scenarios, the operation of renaming directories becomes helpful and it is a common task that we often encounter in Python file management. There is provision of several modules and methods in Python that makes renaming directories an easy task. In this article, we explore different ways how you can rename directories using Python code. You will learn this skill by practicing the code examples and explanations discussed in this article. Making Use of the OS Module ... Read More

How to write single line comment in Java?

mkotla
Updated on 30-Jul-2019 22:30:20

457 Views

To comment a particular line just place ‘double back slash (//)’ before the line as shown below. // Hello this line is commented Example Following example demonstrates the usage of single line comments in Java. Live Demo public class CommentsExample { public static void main(String args[]) { //Declaring a variable named num int num = 1; //Printing the value of the variable num System.out.println("value if the variable num: "+num); } } Output value if the variable num: 1

Is there a need to import Java.lang package while running Java programs?

Sreemaha
Updated on 30-Jul-2019 22:30:20

525 Views

The java.lang package is the default package in Java, by default, it will be imported. Therefore, there is no need to import this package explicitly. i.e. without importing you can access the classes of this package. Example If you observe the following example here we haven’t imported the lang package explicitly but, still, we are able to calculate the square root of a number using the sqrt() method of the java.lang.Math class. Live Demo public class LangTest { public static void main(String args[]) { int num = 100; ... Read More

What environment variables do I need to set up before I start running Java programs on my machine?

varma
Updated on 18-Feb-2020 11:03:23

736 Views

Before running Java programs on your machine you need to set two environment variables namely, PATH − The path environment variable is used to specify the set of directories which contains execution programs.When you try to execute a program from command line, the operating system searches for the specified program in the current directly, if available, executes it.In case the programs are not available in the current directory, operating system verifies in the set of directories specified in the ‘PATH’ environment variable.CLASSPATH − The classpath environment variable is used to specify the location of the classes and packages.When we try ... Read More

How to use labels in Java code?

usharani
Updated on 16-Jun-2020 06:29:04

9K+ Views

Java provides two types of branching/control statements namely, break and continue.The break statementThis statement terminates the loop or switch statement and transfers execution to the statement immediately following the loop or switch.ExampleFollowing is the example of the break statement. Here we are trying to print elements up to 10 and, using break statement we are terminating the loop when the value in the loop reaches 8.Live Demopublic class BreakExample {    public static void main(String args[]){       for(int i=0; i

Are static methods inherited in Java?

mkotla
Updated on 30-Jul-2019 22:30:20

6K+ Views

The static keyword is used to create methods that will exist independently of any instances created for the class. Static methods do not use any instance variables of any object of the class they are defined in. Static methods take all the data from parameters and compute something from those parameters, with no reference to variables. We can inherit static methods in Java. Example In the example we are creating a class named Demo and, declared a static method named display(). We created another class Sample, extended the Demo class and tried to access the display() method using the sub ... Read More

How to write, generate and use Javadoc in Eclipse?

varun
Updated on 18-Feb-2020 10:57:46

10K+ Views

To generate Java docs for your project you need to write the required information about the field, method or class as./**    *    * The method prints a simple message on the Console.    * */Then to generate the document follow the steps given below −Step 1 − Open eclipse, select the option Project →Generate Javadoc.Step 2 − Select the javadoc.exe file from the bin folder of java installation directory, select the destination folder for the generated java doc and select Next.Step 3 − Type the title of the documentation in the Document title and select thefinish button.Step 4 ... Read More

Can you extend a static inner class in Java?

Giri Raju
Updated on 30-Jul-2019 22:30:20

2K+ Views

A static inner class is a nested class which is a static member of the outer class. It can be accessed without instantiating the outer class, using other static members. Just like static members, a static nested class does not have access to the instance variables and methods of the outer class. You can extend static inner class with another inner class. Example Live Demo public class SampleClass { static abstract class Test{ int num = 300; public abstract void display(); ... Read More

Advertisements