
How To Use Python Raw String
### Introduction You can create a raw string in Python by prefixing a string literal with `r` or `R`. Python raw string treats the backslash character (\\) as a literal character. Raw string is useful when a string needs to contain a backslash, such as for a regular expression or Windows directory path, and you don't want it to be treated as an escape character. This article covers the basics of how Python raw strings work and provides...
How To Remove Characters from a String in Python
### Introduction This article describes two common methods that you can use to remove characters from a string using Python: * the `String replace()` method * the `String translate()` method To learn some different ways to remove spaces from a string in Python, refer to [Remove Spaces from a String in Python](https://www.digitalocean.com/community/tutorials/python-remove-spaces-from-string). A Python String object is immutable, so you...

Java is Pass by Value, Not Pass by Reference
### Introduction Many Java programmers question whether Java is _pass by value_ or _pass by reference_. This article summarizes why Java is always pass by value. First, what does pass by value and pass by reference mean? - Pass by value: The method parameter values are copied to another variable and then the copied object is passed to the method. The method uses the copy. - Pass by reference: An alias or reference to the actual...


Java String Interview Questions and Answers
### Introduction `String` is one of the most widely used Java classes. This article provides some practice questions and answers about `String` to help you prepare for an interview. You can also try the [Java String Quiz](/community/tutorials/java-string-quiz) to test your knowledge of the `String` class. ## What is the `String` class in Java? Is `String` a data type? `String` is a class in Java and is defined in the `java.lang`...

How To Use Java HttpURLConnection for HTTP GET and POST Requests
### Introduction The `HttpURLConnection` class from `java.net` package can be used to send a Java HTTP Request programmatically. In this article, you will learn how to use `HttpURLConnection` in a Java program to send `GET` and `POST` requests and then print the response. ## Prerequisites For this `HttpURLConnection` example, you should have completed the [Spring MVC Tutorial](/community/tutorials/spring-mvc-tutorial) because it has...

![public static void main(String[] args) - Java main method](https://laptrinhx.com/cdn/laptrinhx.png)
Java Singleton Design Pattern Best Practices with Examples
### Introduction _Java Singleton Pattern_ is one of the [_Gangs of Four Design patterns_](https://www.digitalocean.com/community/tutorials/gangs-of-four-gof-design-patterns) and comes in the _Creational Design Pattern_ category. From the definition, it seems to be a straightforward design pattern, but when it comes to implementation, it comes with a lot of concerns. In this article, we will learn about singleton design pattern...

Overriding vs Overloading in Java
### Introduction _Overriding_ and _overloading_ are the core concepts in Java programming. They are the ways to implement polymorphism in our Java programs. Polymorphism is one of the [OOPS Concepts](/community/tutorials/oops-concepts-java-example). , [`np.array`] objects can be converted to a list with the `tolist()` function. The `tolist()` function doesn't accept any arguments. If the array is one-dimensional, a list with the array elements is returned. For a multi-dimensional array, a nested list is returned. ## Converting one-dimensional NumPy Array to List Let's construct a one-dimensional array of...
How to add Elements to a List in Python
### Introduction In this tutorial, we will learn different ways to add elements to a list in Python. There are four methods to add elements to a List in Python. 1. `append()`: append the element to the end of the list. 2. `insert()`: inserts the element before the given index. 3. `extend()`: extends the list by appending elements from the iterable. 4. List Concatenation: We can use the `+` operator to concatenate multiple lists and...
Visitor Design Pattern in Java
Visitor Design Pattern is one of the behavioral design pattern. ## Visitor Design Pattern Visitor pattern is used when we have to perform an operation on a group of similar kind of Objects. With the help of visitor pattern, we can move the operational logic from the objects to another class. For example, think of a Shopping cart where we can add different type of items (Elements). When we click on checkout button, it calculates the...

"The method X is ambiguous for the type Y" Java ambiguous method call null error
If you are reading this, chances are you got `The method X is ambiguous for the type Y` error when compiling a java program in terminal or in any Java IDE. ## Java ambiguous method call Here I am going to explain why...

Thread Life Cycle in Java - Thread States in Java
Understanding **Thread Life Cycle in Java** and **Thread States** are very important when you are working with Threads and programming for multithreaded environment. From our last tutorial, we can create a [java thread](/community/tutorials/java-thread-example "Java Thread Example – Extending Thread Class and Implementing Runnable Interface") class by implementing Runnable interface or by extending Thread class, but to...