Adding fields on button click





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







0















I need to add a bunch of Labels and TextFields on button click.
In this case I need to add them as code right, not in the FXML?



I have Automobile class and I have to add like 10 labels and text fields when the user clicks a "Add Automobile" button.
Is there a better way than adding them like this:



Label label = new Label("State registration number:");
TextField textField1 = new TextField();
Label label2 = new Label("Brand:");
TextField textField2 = new TextField();
Label label3 = new Label("Model:");
TextField textField3 = new TextField();
Label label4 = new Label("Year of production:");


And so on... And if I need to add to them some other attributes, I need to write like 30+ more lines. Is there a better way of doing this? What is the best practice?










share|improve this question























  • You do not add anything in your code snippet. Depending on the layout/scene structure you use there could be a way of doing this that requires less repeated code, but that depends. Could you add info about what you're doning with those objects except for creating them?

    – fabian
    Nov 23 '18 at 13:00











  • Hello @fabian, thanks for your reply! I have a scene with three buttons - for adding, updating and deleting an automobile. If the user clicks on the adding button, I want to create labels and text fields, so the user can enter the automobile's data. Then it will add it to a database.

    – Kristiyan
    Nov 23 '18 at 13:16











  • Now when the user wants to update an automobile's data, he should click on the updating button. Then I want to clear all the labels and text fields and to create a combo box for the user to choose which automobile to update. After he chooses the automobile's registration number, I want to recreate all the labels and textfield with the chosen automobile's data inside them.

    – Kristiyan
    Nov 23 '18 at 13:16


















0















I need to add a bunch of Labels and TextFields on button click.
In this case I need to add them as code right, not in the FXML?



I have Automobile class and I have to add like 10 labels and text fields when the user clicks a "Add Automobile" button.
Is there a better way than adding them like this:



Label label = new Label("State registration number:");
TextField textField1 = new TextField();
Label label2 = new Label("Brand:");
TextField textField2 = new TextField();
Label label3 = new Label("Model:");
TextField textField3 = new TextField();
Label label4 = new Label("Year of production:");


And so on... And if I need to add to them some other attributes, I need to write like 30+ more lines. Is there a better way of doing this? What is the best practice?










share|improve this question























  • You do not add anything in your code snippet. Depending on the layout/scene structure you use there could be a way of doing this that requires less repeated code, but that depends. Could you add info about what you're doning with those objects except for creating them?

    – fabian
    Nov 23 '18 at 13:00











  • Hello @fabian, thanks for your reply! I have a scene with three buttons - for adding, updating and deleting an automobile. If the user clicks on the adding button, I want to create labels and text fields, so the user can enter the automobile's data. Then it will add it to a database.

    – Kristiyan
    Nov 23 '18 at 13:16











  • Now when the user wants to update an automobile's data, he should click on the updating button. Then I want to clear all the labels and text fields and to create a combo box for the user to choose which automobile to update. After he chooses the automobile's registration number, I want to recreate all the labels and textfield with the chosen automobile's data inside them.

    – Kristiyan
    Nov 23 '18 at 13:16














0












0








0








I need to add a bunch of Labels and TextFields on button click.
In this case I need to add them as code right, not in the FXML?



I have Automobile class and I have to add like 10 labels and text fields when the user clicks a "Add Automobile" button.
Is there a better way than adding them like this:



Label label = new Label("State registration number:");
TextField textField1 = new TextField();
Label label2 = new Label("Brand:");
TextField textField2 = new TextField();
Label label3 = new Label("Model:");
TextField textField3 = new TextField();
Label label4 = new Label("Year of production:");


And so on... And if I need to add to them some other attributes, I need to write like 30+ more lines. Is there a better way of doing this? What is the best practice?










share|improve this question














I need to add a bunch of Labels and TextFields on button click.
In this case I need to add them as code right, not in the FXML?



I have Automobile class and I have to add like 10 labels and text fields when the user clicks a "Add Automobile" button.
Is there a better way than adding them like this:



Label label = new Label("State registration number:");
TextField textField1 = new TextField();
Label label2 = new Label("Brand:");
TextField textField2 = new TextField();
Label label3 = new Label("Model:");
TextField textField3 = new TextField();
Label label4 = new Label("Year of production:");


And so on... And if I need to add to them some other attributes, I need to write like 30+ more lines. Is there a better way of doing this? What is the best practice?







java javafx label






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 23 '18 at 12:48









KristiyanKristiyan

197




197













  • You do not add anything in your code snippet. Depending on the layout/scene structure you use there could be a way of doing this that requires less repeated code, but that depends. Could you add info about what you're doning with those objects except for creating them?

    – fabian
    Nov 23 '18 at 13:00











  • Hello @fabian, thanks for your reply! I have a scene with three buttons - for adding, updating and deleting an automobile. If the user clicks on the adding button, I want to create labels and text fields, so the user can enter the automobile's data. Then it will add it to a database.

    – Kristiyan
    Nov 23 '18 at 13:16











  • Now when the user wants to update an automobile's data, he should click on the updating button. Then I want to clear all the labels and text fields and to create a combo box for the user to choose which automobile to update. After he chooses the automobile's registration number, I want to recreate all the labels and textfield with the chosen automobile's data inside them.

    – Kristiyan
    Nov 23 '18 at 13:16



















  • You do not add anything in your code snippet. Depending on the layout/scene structure you use there could be a way of doing this that requires less repeated code, but that depends. Could you add info about what you're doning with those objects except for creating them?

    – fabian
    Nov 23 '18 at 13:00











  • Hello @fabian, thanks for your reply! I have a scene with three buttons - for adding, updating and deleting an automobile. If the user clicks on the adding button, I want to create labels and text fields, so the user can enter the automobile's data. Then it will add it to a database.

    – Kristiyan
    Nov 23 '18 at 13:16











  • Now when the user wants to update an automobile's data, he should click on the updating button. Then I want to clear all the labels and text fields and to create a combo box for the user to choose which automobile to update. After he chooses the automobile's registration number, I want to recreate all the labels and textfield with the chosen automobile's data inside them.

    – Kristiyan
    Nov 23 '18 at 13:16

















You do not add anything in your code snippet. Depending on the layout/scene structure you use there could be a way of doing this that requires less repeated code, but that depends. Could you add info about what you're doning with those objects except for creating them?

– fabian
Nov 23 '18 at 13:00





You do not add anything in your code snippet. Depending on the layout/scene structure you use there could be a way of doing this that requires less repeated code, but that depends. Could you add info about what you're doning with those objects except for creating them?

– fabian
Nov 23 '18 at 13:00













Hello @fabian, thanks for your reply! I have a scene with three buttons - for adding, updating and deleting an automobile. If the user clicks on the adding button, I want to create labels and text fields, so the user can enter the automobile's data. Then it will add it to a database.

– Kristiyan
Nov 23 '18 at 13:16





Hello @fabian, thanks for your reply! I have a scene with three buttons - for adding, updating and deleting an automobile. If the user clicks on the adding button, I want to create labels and text fields, so the user can enter the automobile's data. Then it will add it to a database.

– Kristiyan
Nov 23 '18 at 13:16













Now when the user wants to update an automobile's data, he should click on the updating button. Then I want to clear all the labels and text fields and to create a combo box for the user to choose which automobile to update. After he chooses the automobile's registration number, I want to recreate all the labels and textfield with the chosen automobile's data inside them.

– Kristiyan
Nov 23 '18 at 13:16





Now when the user wants to update an automobile's data, he should click on the updating button. Then I want to clear all the labels and text fields and to create a combo box for the user to choose which automobile to update. After he chooses the automobile's registration number, I want to recreate all the labels and textfield with the chosen automobile's data inside them.

– Kristiyan
Nov 23 '18 at 13:16












2 Answers
2






active

oldest

votes


















0














It's not the greatest solution but a good base to start with



import java.util.Arrays;
import java.util.List;
import java.util.Optional;

import javafx.application.Application;
import javafx.beans.value.ChangeListener;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

public class MultipleLabelTextFiledApp extends Application {
private final ObservableList<CustomControl> customControls = FXCollections.observableArrayList();
private final List<String> labels = Arrays.asList("label1", "label2", "label3", "label4", "label5");

public static void main(String args) {
launch(args);
}

@Override
public void start(Stage stage) throws Exception {

labels.stream().forEach(label -> customControls.add(new CustomControl(label)));

VBox vBox = new VBox();
vBox.getChildren().setAll(customControls);

stage.setScene(new Scene(vBox));
stage.show();

getCustomControl("label1").ifPresent(customControl -> {
customControl.getTextField().textProperty().addListener((ChangeListener<String>) (observable, oldValue, newValue) -> {
System.out.println("textField with label1 handler new text=" + newValue);
});
});
}

private Optional<CustomControl> getCustomControl(String labelText) {
return customControls.stream()
.filter(customControl -> labelText.equals(customControl.getLabel().getText()))
.findFirst();
}
}

class CustomControl extends HBox {

private final Label label = new Label();
private final TextField textField = new TextField();

{
getChildren().addAll(label, textField);
}

public CustomControl(String text) {
label.setText(text);
}

public Label getLabel() {
return label;
}

public TextField getTextField() {
return textField;
}
}





share|improve this answer
























  • Thank you very much! I'll try to implement it.

    – Kristiyan
    Nov 23 '18 at 14:02





















0














First what you need is an int variable which its value is the amount of labels and textfields you want to create, it would be:



int amount = 10;


You should declare three arrays: One wich contains the text of the labels it would be:



String  text_labels = new String  {"State registration number:", "Brand:", "Model:", "..."};


Then you should declare the second array which may be:



Label  labels = new Label[amount];


And the third one:



TextField  textfields = new Text field[amount];


Once you haved declared them you have to initialize the labels and textfields. In order to do so you can do:



for(int i = 0; i < amount; i ++) {
Label label = new Label(text_labels[i]);
TextField textField = new TextField();
labels[i] = label;
textfields[i] = textField;
}


So labels[0] would be the same as the first label you wrote in your code and the same with the textfields.






share|improve this answer


























  • You're not allowed to specify the number of items in java, if you're initializing the array. Furthermore you're not allowed to specify the number of items in the declaration. Arrays are created using new ElementType[elementCount] or new ElementType { ...values... }; new String[1] {"Hello World"} yields a compile time error though...

    – fabian
    Nov 23 '18 at 13:27











  • True, I'm going to change it

    – alber6morci
    Nov 23 '18 at 14:04












Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53447025%2fadding-fields-on-button-click%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














It's not the greatest solution but a good base to start with



import java.util.Arrays;
import java.util.List;
import java.util.Optional;

import javafx.application.Application;
import javafx.beans.value.ChangeListener;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

public class MultipleLabelTextFiledApp extends Application {
private final ObservableList<CustomControl> customControls = FXCollections.observableArrayList();
private final List<String> labels = Arrays.asList("label1", "label2", "label3", "label4", "label5");

public static void main(String args) {
launch(args);
}

@Override
public void start(Stage stage) throws Exception {

labels.stream().forEach(label -> customControls.add(new CustomControl(label)));

VBox vBox = new VBox();
vBox.getChildren().setAll(customControls);

stage.setScene(new Scene(vBox));
stage.show();

getCustomControl("label1").ifPresent(customControl -> {
customControl.getTextField().textProperty().addListener((ChangeListener<String>) (observable, oldValue, newValue) -> {
System.out.println("textField with label1 handler new text=" + newValue);
});
});
}

private Optional<CustomControl> getCustomControl(String labelText) {
return customControls.stream()
.filter(customControl -> labelText.equals(customControl.getLabel().getText()))
.findFirst();
}
}

class CustomControl extends HBox {

private final Label label = new Label();
private final TextField textField = new TextField();

{
getChildren().addAll(label, textField);
}

public CustomControl(String text) {
label.setText(text);
}

public Label getLabel() {
return label;
}

public TextField getTextField() {
return textField;
}
}





share|improve this answer
























  • Thank you very much! I'll try to implement it.

    – Kristiyan
    Nov 23 '18 at 14:02


















0














It's not the greatest solution but a good base to start with



import java.util.Arrays;
import java.util.List;
import java.util.Optional;

import javafx.application.Application;
import javafx.beans.value.ChangeListener;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

public class MultipleLabelTextFiledApp extends Application {
private final ObservableList<CustomControl> customControls = FXCollections.observableArrayList();
private final List<String> labels = Arrays.asList("label1", "label2", "label3", "label4", "label5");

public static void main(String args) {
launch(args);
}

@Override
public void start(Stage stage) throws Exception {

labels.stream().forEach(label -> customControls.add(new CustomControl(label)));

VBox vBox = new VBox();
vBox.getChildren().setAll(customControls);

stage.setScene(new Scene(vBox));
stage.show();

getCustomControl("label1").ifPresent(customControl -> {
customControl.getTextField().textProperty().addListener((ChangeListener<String>) (observable, oldValue, newValue) -> {
System.out.println("textField with label1 handler new text=" + newValue);
});
});
}

private Optional<CustomControl> getCustomControl(String labelText) {
return customControls.stream()
.filter(customControl -> labelText.equals(customControl.getLabel().getText()))
.findFirst();
}
}

class CustomControl extends HBox {

private final Label label = new Label();
private final TextField textField = new TextField();

{
getChildren().addAll(label, textField);
}

public CustomControl(String text) {
label.setText(text);
}

public Label getLabel() {
return label;
}

public TextField getTextField() {
return textField;
}
}





share|improve this answer
























  • Thank you very much! I'll try to implement it.

    – Kristiyan
    Nov 23 '18 at 14:02
















0












0








0







It's not the greatest solution but a good base to start with



import java.util.Arrays;
import java.util.List;
import java.util.Optional;

import javafx.application.Application;
import javafx.beans.value.ChangeListener;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

public class MultipleLabelTextFiledApp extends Application {
private final ObservableList<CustomControl> customControls = FXCollections.observableArrayList();
private final List<String> labels = Arrays.asList("label1", "label2", "label3", "label4", "label5");

public static void main(String args) {
launch(args);
}

@Override
public void start(Stage stage) throws Exception {

labels.stream().forEach(label -> customControls.add(new CustomControl(label)));

VBox vBox = new VBox();
vBox.getChildren().setAll(customControls);

stage.setScene(new Scene(vBox));
stage.show();

getCustomControl("label1").ifPresent(customControl -> {
customControl.getTextField().textProperty().addListener((ChangeListener<String>) (observable, oldValue, newValue) -> {
System.out.println("textField with label1 handler new text=" + newValue);
});
});
}

private Optional<CustomControl> getCustomControl(String labelText) {
return customControls.stream()
.filter(customControl -> labelText.equals(customControl.getLabel().getText()))
.findFirst();
}
}

class CustomControl extends HBox {

private final Label label = new Label();
private final TextField textField = new TextField();

{
getChildren().addAll(label, textField);
}

public CustomControl(String text) {
label.setText(text);
}

public Label getLabel() {
return label;
}

public TextField getTextField() {
return textField;
}
}





share|improve this answer













It's not the greatest solution but a good base to start with



import java.util.Arrays;
import java.util.List;
import java.util.Optional;

import javafx.application.Application;
import javafx.beans.value.ChangeListener;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

public class MultipleLabelTextFiledApp extends Application {
private final ObservableList<CustomControl> customControls = FXCollections.observableArrayList();
private final List<String> labels = Arrays.asList("label1", "label2", "label3", "label4", "label5");

public static void main(String args) {
launch(args);
}

@Override
public void start(Stage stage) throws Exception {

labels.stream().forEach(label -> customControls.add(new CustomControl(label)));

VBox vBox = new VBox();
vBox.getChildren().setAll(customControls);

stage.setScene(new Scene(vBox));
stage.show();

getCustomControl("label1").ifPresent(customControl -> {
customControl.getTextField().textProperty().addListener((ChangeListener<String>) (observable, oldValue, newValue) -> {
System.out.println("textField with label1 handler new text=" + newValue);
});
});
}

private Optional<CustomControl> getCustomControl(String labelText) {
return customControls.stream()
.filter(customControl -> labelText.equals(customControl.getLabel().getText()))
.findFirst();
}
}

class CustomControl extends HBox {

private final Label label = new Label();
private final TextField textField = new TextField();

{
getChildren().addAll(label, textField);
}

public CustomControl(String text) {
label.setText(text);
}

public Label getLabel() {
return label;
}

public TextField getTextField() {
return textField;
}
}






share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 23 '18 at 13:35









Przemek KrysztofiakPrzemek Krysztofiak

2768




2768













  • Thank you very much! I'll try to implement it.

    – Kristiyan
    Nov 23 '18 at 14:02





















  • Thank you very much! I'll try to implement it.

    – Kristiyan
    Nov 23 '18 at 14:02



















Thank you very much! I'll try to implement it.

– Kristiyan
Nov 23 '18 at 14:02







Thank you very much! I'll try to implement it.

– Kristiyan
Nov 23 '18 at 14:02















0














First what you need is an int variable which its value is the amount of labels and textfields you want to create, it would be:



int amount = 10;


You should declare three arrays: One wich contains the text of the labels it would be:



String  text_labels = new String  {"State registration number:", "Brand:", "Model:", "..."};


Then you should declare the second array which may be:



Label  labels = new Label[amount];


And the third one:



TextField  textfields = new Text field[amount];


Once you haved declared them you have to initialize the labels and textfields. In order to do so you can do:



for(int i = 0; i < amount; i ++) {
Label label = new Label(text_labels[i]);
TextField textField = new TextField();
labels[i] = label;
textfields[i] = textField;
}


So labels[0] would be the same as the first label you wrote in your code and the same with the textfields.






share|improve this answer


























  • You're not allowed to specify the number of items in java, if you're initializing the array. Furthermore you're not allowed to specify the number of items in the declaration. Arrays are created using new ElementType[elementCount] or new ElementType { ...values... }; new String[1] {"Hello World"} yields a compile time error though...

    – fabian
    Nov 23 '18 at 13:27











  • True, I'm going to change it

    – alber6morci
    Nov 23 '18 at 14:04
















0














First what you need is an int variable which its value is the amount of labels and textfields you want to create, it would be:



int amount = 10;


You should declare three arrays: One wich contains the text of the labels it would be:



String  text_labels = new String  {"State registration number:", "Brand:", "Model:", "..."};


Then you should declare the second array which may be:



Label  labels = new Label[amount];


And the third one:



TextField  textfields = new Text field[amount];


Once you haved declared them you have to initialize the labels and textfields. In order to do so you can do:



for(int i = 0; i < amount; i ++) {
Label label = new Label(text_labels[i]);
TextField textField = new TextField();
labels[i] = label;
textfields[i] = textField;
}


So labels[0] would be the same as the first label you wrote in your code and the same with the textfields.






share|improve this answer


























  • You're not allowed to specify the number of items in java, if you're initializing the array. Furthermore you're not allowed to specify the number of items in the declaration. Arrays are created using new ElementType[elementCount] or new ElementType { ...values... }; new String[1] {"Hello World"} yields a compile time error though...

    – fabian
    Nov 23 '18 at 13:27











  • True, I'm going to change it

    – alber6morci
    Nov 23 '18 at 14:04














0












0








0







First what you need is an int variable which its value is the amount of labels and textfields you want to create, it would be:



int amount = 10;


You should declare three arrays: One wich contains the text of the labels it would be:



String  text_labels = new String  {"State registration number:", "Brand:", "Model:", "..."};


Then you should declare the second array which may be:



Label  labels = new Label[amount];


And the third one:



TextField  textfields = new Text field[amount];


Once you haved declared them you have to initialize the labels and textfields. In order to do so you can do:



for(int i = 0; i < amount; i ++) {
Label label = new Label(text_labels[i]);
TextField textField = new TextField();
labels[i] = label;
textfields[i] = textField;
}


So labels[0] would be the same as the first label you wrote in your code and the same with the textfields.






share|improve this answer















First what you need is an int variable which its value is the amount of labels and textfields you want to create, it would be:



int amount = 10;


You should declare three arrays: One wich contains the text of the labels it would be:



String  text_labels = new String  {"State registration number:", "Brand:", "Model:", "..."};


Then you should declare the second array which may be:



Label  labels = new Label[amount];


And the third one:



TextField  textfields = new Text field[amount];


Once you haved declared them you have to initialize the labels and textfields. In order to do so you can do:



for(int i = 0; i < amount; i ++) {
Label label = new Label(text_labels[i]);
TextField textField = new TextField();
labels[i] = label;
textfields[i] = textField;
}


So labels[0] would be the same as the first label you wrote in your code and the same with the textfields.







share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 23 '18 at 14:40

























answered Nov 23 '18 at 13:13









alber6morcialber6morci

114




114













  • You're not allowed to specify the number of items in java, if you're initializing the array. Furthermore you're not allowed to specify the number of items in the declaration. Arrays are created using new ElementType[elementCount] or new ElementType { ...values... }; new String[1] {"Hello World"} yields a compile time error though...

    – fabian
    Nov 23 '18 at 13:27











  • True, I'm going to change it

    – alber6morci
    Nov 23 '18 at 14:04



















  • You're not allowed to specify the number of items in java, if you're initializing the array. Furthermore you're not allowed to specify the number of items in the declaration. Arrays are created using new ElementType[elementCount] or new ElementType { ...values... }; new String[1] {"Hello World"} yields a compile time error though...

    – fabian
    Nov 23 '18 at 13:27











  • True, I'm going to change it

    – alber6morci
    Nov 23 '18 at 14:04

















You're not allowed to specify the number of items in java, if you're initializing the array. Furthermore you're not allowed to specify the number of items in the declaration. Arrays are created using new ElementType[elementCount] or new ElementType { ...values... }; new String[1] {"Hello World"} yields a compile time error though...

– fabian
Nov 23 '18 at 13:27





You're not allowed to specify the number of items in java, if you're initializing the array. Furthermore you're not allowed to specify the number of items in the declaration. Arrays are created using new ElementType[elementCount] or new ElementType { ...values... }; new String[1] {"Hello World"} yields a compile time error though...

– fabian
Nov 23 '18 at 13:27













True, I'm going to change it

– alber6morci
Nov 23 '18 at 14:04





True, I'm going to change it

– alber6morci
Nov 23 '18 at 14:04


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53447025%2fadding-fields-on-button-click%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

"Incorrect syntax near the keyword 'ON'. (on update cascade, on delete cascade,)

Alcedinidae

Origin of the phrase “under your belt”?