---
title: "Does Java support default parameter values?"  
description: "Does Java support default parameter values?"  
author: "Anonymous User"  
published: 2015-05-16  
updated: 2015-05-16  
canonical: https://www.mindstick.com/forum/23231/does-java-support-default-parameter-values  
category: "java"  
tags: ["java"]  
reading_time: 1 minute  

---

# Does Java support default parameter values?

I came across some Java [code](https://yourviews.mindstick.com/view/85458/alan-turing-the-mastermind-behind-cracking-the-enigma-code-during-world-war-ii) that had the following [structure](https://www.mindstick.com/articles/23258/choose-your-business-structure-wisely):

```
public MyParameterizedFunction(String param1, int param2){    this(param1, param2, false);}public MyParameterizedFunction(String param1, int param2, boolean param3){    //use all three parameters here}
```

I know that in [C++](https://www.mindstick.com/blog/745/array-in-c-plus-plus) I can assign a [parameter](https://www.mindstick.com/blog/450/parameter-class-in-c-sharp) a [default value](https://www.mindstick.com/forum/2035/default-value-when-using-singleordefault). For example:\
void MyParameterizedFunction([String](https://www.mindstick.com/articles/1527/string-split-in-c-sharp) param1, [int](https://www.mindstick.com/forum/159137/how-to-convert-date-int-to-date-in-sql) param2, bool param3=false);Does Java [support](https://yourviews.mindstick.com/view/286/modi-support-for-sportsperson) this kind of syntax? Are there any [reasons](https://www.mindstick.com/articles/13029/top-4-reasons-to-try-online-casinos) why this two step syntax is preferable?

## Replies

### Reply by Anonymous User

No, the structure you found is how Java handles it (that is, with overloading instead of [default](https://www.mindstick.com/interview/12771/what-is-the-importance-of-default-resources) parameters).

For constructors, [See Effective Java: Programming Language Guide's](https://en.wikipedia.org/wiki/Joshua_Bloch#Bibliography) Item 1 tip (Consider static factory methods instead of constructors) if the overloading is getting complicated. For other methods, renaming some cases or using a parameter object can help. This is when you have enough complexity that differentiating is difficult. A definite case is where you have to differentiate using the order of parameters, not just number and type


---

Original Source: https://www.mindstick.com/forum/23231/does-java-support-default-parameter-values

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
