Displaying Array with JOptionPane
First, this is a school activity, an activity that i cant solve by my own.
i'm a first year college BSIT student and this my first post.
i'm having trouble in displaying my "initialized array" in JOptionPane, i cant find the right code to display them. hope you get my question.
heres my code..
public static void main(String args) {
String display="";
String size = JOptionPane.showInputDialog("Enter Your Prefered Size Of Your Array");
int newsize = Integer.parseInt(size);
JOptionPane.showMessageDialog(null,"You Entered "+newsize+".");
String array = new String[newsize];
for (int a=0; a<array.length;a++)
{
JOptionPane.showInputDialog("Enter Value For Array["+a+"].");
}
for (int a=0;a<array.length;a++)
{
display = display +array[a];
}
JOptionPane.showMessageDialog(null,"n"+array[display]);
}
}
java arrays swing joptionpane
|
show 2 more comments
First, this is a school activity, an activity that i cant solve by my own.
i'm a first year college BSIT student and this my first post.
i'm having trouble in displaying my "initialized array" in JOptionPane, i cant find the right code to display them. hope you get my question.
heres my code..
public static void main(String args) {
String display="";
String size = JOptionPane.showInputDialog("Enter Your Prefered Size Of Your Array");
int newsize = Integer.parseInt(size);
JOptionPane.showMessageDialog(null,"You Entered "+newsize+".");
String array = new String[newsize];
for (int a=0; a<array.length;a++)
{
JOptionPane.showInputDialog("Enter Value For Array["+a+"].");
}
for (int a=0;a<array.length;a++)
{
display = display +array[a];
}
JOptionPane.showMessageDialog(null,"n"+array[display]);
}
}
java arrays swing joptionpane
1) For better help sooner, post an SSCCE. 2) Please use code formatting for code, input/output & structured documents like HTML or XML. To do that, select the sample and click the{}button above the messaged posting/editing form. 3) Please add an upper case letter at the start of sentences. Also use a capital for the word I, and abbreviations and acronyms like JEE or WAR. This makes it easier for people to understand and help. 4) What is your question?
– Andrew Thompson
Nov 11 '13 at 22:28
You just needJOptionPane.showMessageDialog(null,"n"+display);
– Smit
Nov 11 '13 at 22:30
ahhmm, Im sorry, i'm not good in english and i didn't nos. 1-3, and for no. 4. my QUESTION is , how to display all myarrays in JOPtionPane.showMessageDialog.
– jarnthrax
Nov 11 '13 at 22:32
but sir, i get an output "nullnull".
– jarnthrax
Nov 11 '13 at 22:34
@user2981000 Thats because you are not saving your values to array. Refer to answer given by @ Tomas Bisciak
– Smit
Nov 11 '13 at 22:37
|
show 2 more comments
First, this is a school activity, an activity that i cant solve by my own.
i'm a first year college BSIT student and this my first post.
i'm having trouble in displaying my "initialized array" in JOptionPane, i cant find the right code to display them. hope you get my question.
heres my code..
public static void main(String args) {
String display="";
String size = JOptionPane.showInputDialog("Enter Your Prefered Size Of Your Array");
int newsize = Integer.parseInt(size);
JOptionPane.showMessageDialog(null,"You Entered "+newsize+".");
String array = new String[newsize];
for (int a=0; a<array.length;a++)
{
JOptionPane.showInputDialog("Enter Value For Array["+a+"].");
}
for (int a=0;a<array.length;a++)
{
display = display +array[a];
}
JOptionPane.showMessageDialog(null,"n"+array[display]);
}
}
java arrays swing joptionpane
First, this is a school activity, an activity that i cant solve by my own.
i'm a first year college BSIT student and this my first post.
i'm having trouble in displaying my "initialized array" in JOptionPane, i cant find the right code to display them. hope you get my question.
heres my code..
public static void main(String args) {
String display="";
String size = JOptionPane.showInputDialog("Enter Your Prefered Size Of Your Array");
int newsize = Integer.parseInt(size);
JOptionPane.showMessageDialog(null,"You Entered "+newsize+".");
String array = new String[newsize];
for (int a=0; a<array.length;a++)
{
JOptionPane.showInputDialog("Enter Value For Array["+a+"].");
}
for (int a=0;a<array.length;a++)
{
display = display +array[a];
}
JOptionPane.showMessageDialog(null,"n"+array[display]);
}
}
java arrays swing joptionpane
java arrays swing joptionpane
edited Nov 11 '13 at 22:28
Smit
4,17112027
4,17112027
asked Nov 11 '13 at 22:27
jarnthrax
761311
761311
1) For better help sooner, post an SSCCE. 2) Please use code formatting for code, input/output & structured documents like HTML or XML. To do that, select the sample and click the{}button above the messaged posting/editing form. 3) Please add an upper case letter at the start of sentences. Also use a capital for the word I, and abbreviations and acronyms like JEE or WAR. This makes it easier for people to understand and help. 4) What is your question?
– Andrew Thompson
Nov 11 '13 at 22:28
You just needJOptionPane.showMessageDialog(null,"n"+display);
– Smit
Nov 11 '13 at 22:30
ahhmm, Im sorry, i'm not good in english and i didn't nos. 1-3, and for no. 4. my QUESTION is , how to display all myarrays in JOPtionPane.showMessageDialog.
– jarnthrax
Nov 11 '13 at 22:32
but sir, i get an output "nullnull".
– jarnthrax
Nov 11 '13 at 22:34
@user2981000 Thats because you are not saving your values to array. Refer to answer given by @ Tomas Bisciak
– Smit
Nov 11 '13 at 22:37
|
show 2 more comments
1) For better help sooner, post an SSCCE. 2) Please use code formatting for code, input/output & structured documents like HTML or XML. To do that, select the sample and click the{}button above the messaged posting/editing form. 3) Please add an upper case letter at the start of sentences. Also use a capital for the word I, and abbreviations and acronyms like JEE or WAR. This makes it easier for people to understand and help. 4) What is your question?
– Andrew Thompson
Nov 11 '13 at 22:28
You just needJOptionPane.showMessageDialog(null,"n"+display);
– Smit
Nov 11 '13 at 22:30
ahhmm, Im sorry, i'm not good in english and i didn't nos. 1-3, and for no. 4. my QUESTION is , how to display all myarrays in JOPtionPane.showMessageDialog.
– jarnthrax
Nov 11 '13 at 22:32
but sir, i get an output "nullnull".
– jarnthrax
Nov 11 '13 at 22:34
@user2981000 Thats because you are not saving your values to array. Refer to answer given by @ Tomas Bisciak
– Smit
Nov 11 '13 at 22:37
1) For better help sooner, post an SSCCE. 2) Please use code formatting for code, input/output & structured documents like HTML or XML. To do that, select the sample and click the
{} button above the messaged posting/editing form. 3) Please add an upper case letter at the start of sentences. Also use a capital for the word I, and abbreviations and acronyms like JEE or WAR. This makes it easier for people to understand and help. 4) What is your question?– Andrew Thompson
Nov 11 '13 at 22:28
1) For better help sooner, post an SSCCE. 2) Please use code formatting for code, input/output & structured documents like HTML or XML. To do that, select the sample and click the
{} button above the messaged posting/editing form. 3) Please add an upper case letter at the start of sentences. Also use a capital for the word I, and abbreviations and acronyms like JEE or WAR. This makes it easier for people to understand and help. 4) What is your question?– Andrew Thompson
Nov 11 '13 at 22:28
You just need
JOptionPane.showMessageDialog(null,"n"+display);– Smit
Nov 11 '13 at 22:30
You just need
JOptionPane.showMessageDialog(null,"n"+display);– Smit
Nov 11 '13 at 22:30
ahhmm, Im sorry, i'm not good in english and i didn't nos. 1-3, and for no. 4. my QUESTION is , how to display all myarrays in JOPtionPane.showMessageDialog.
– jarnthrax
Nov 11 '13 at 22:32
ahhmm, Im sorry, i'm not good in english and i didn't nos. 1-3, and for no. 4. my QUESTION is , how to display all myarrays in JOPtionPane.showMessageDialog.
– jarnthrax
Nov 11 '13 at 22:32
but sir, i get an output "nullnull".
– jarnthrax
Nov 11 '13 at 22:34
but sir, i get an output "nullnull".
– jarnthrax
Nov 11 '13 at 22:34
@user2981000 Thats because you are not saving your values to array. Refer to answer given by @ Tomas Bisciak
– Smit
Nov 11 '13 at 22:37
@user2981000 Thats because you are not saving your values to array. Refer to answer given by @ Tomas Bisciak
– Smit
Nov 11 '13 at 22:37
|
show 2 more comments
2 Answers
2
active
oldest
votes
JOptionPane.showInputDialog("Enter Value For Array["+a+"].");
shoud be
array[a]=JOptionPane.showInputDialog("Enter Value For Array["+a+"].");
and then make string
for (int a=0;a<array.length;a++)
{
display+=array[a]+","
}
after that just print it out :)
for new line display+=array[a]+"n"
sir, iget the same output, null,null.
– jarnthrax
Nov 11 '13 at 22:39
yes, it works. but i want to make a new line for the next set of array. thanks @Tomas Bisciak
– jarnthrax
Nov 11 '13 at 22:41
for new line display+=array[a]+"n"
– Tomas Bisciak
Nov 11 '13 at 22:43
great! Thakn you so much guys. i hava to go now, i have 7:30 class. SALAMAT!!!!
– jarnthrax
Nov 11 '13 at 22:47
add a comment |
you could do that in 1 loop.
For example:
public static void main(String args) {
String display="";
String size = JOptionPane.showInputDialog("Enter Your Prefered Size Of Your Array");
int newsize = Integer.parseInt(size);
JOptionPane.showMessageDialog(null,"You Entered "+newsize+".");
String array = new String[newsize];
for (int a=0; a<array.length;a++)
{
array[a] = JOptionPane.showInputDialog("Enter Value For Array["+a+"].");
display = display +array[a] + "n";
}
JOptionPane.showMessageDialog(null,display);
}
}
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f19917221%2fdisplaying-array-with-joptionpane%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
JOptionPane.showInputDialog("Enter Value For Array["+a+"].");
shoud be
array[a]=JOptionPane.showInputDialog("Enter Value For Array["+a+"].");
and then make string
for (int a=0;a<array.length;a++)
{
display+=array[a]+","
}
after that just print it out :)
for new line display+=array[a]+"n"
sir, iget the same output, null,null.
– jarnthrax
Nov 11 '13 at 22:39
yes, it works. but i want to make a new line for the next set of array. thanks @Tomas Bisciak
– jarnthrax
Nov 11 '13 at 22:41
for new line display+=array[a]+"n"
– Tomas Bisciak
Nov 11 '13 at 22:43
great! Thakn you so much guys. i hava to go now, i have 7:30 class. SALAMAT!!!!
– jarnthrax
Nov 11 '13 at 22:47
add a comment |
JOptionPane.showInputDialog("Enter Value For Array["+a+"].");
shoud be
array[a]=JOptionPane.showInputDialog("Enter Value For Array["+a+"].");
and then make string
for (int a=0;a<array.length;a++)
{
display+=array[a]+","
}
after that just print it out :)
for new line display+=array[a]+"n"
sir, iget the same output, null,null.
– jarnthrax
Nov 11 '13 at 22:39
yes, it works. but i want to make a new line for the next set of array. thanks @Tomas Bisciak
– jarnthrax
Nov 11 '13 at 22:41
for new line display+=array[a]+"n"
– Tomas Bisciak
Nov 11 '13 at 22:43
great! Thakn you so much guys. i hava to go now, i have 7:30 class. SALAMAT!!!!
– jarnthrax
Nov 11 '13 at 22:47
add a comment |
JOptionPane.showInputDialog("Enter Value For Array["+a+"].");
shoud be
array[a]=JOptionPane.showInputDialog("Enter Value For Array["+a+"].");
and then make string
for (int a=0;a<array.length;a++)
{
display+=array[a]+","
}
after that just print it out :)
for new line display+=array[a]+"n"
JOptionPane.showInputDialog("Enter Value For Array["+a+"].");
shoud be
array[a]=JOptionPane.showInputDialog("Enter Value For Array["+a+"].");
and then make string
for (int a=0;a<array.length;a++)
{
display+=array[a]+","
}
after that just print it out :)
for new line display+=array[a]+"n"
edited Nov 11 '13 at 22:45
Smit
4,17112027
4,17112027
answered Nov 11 '13 at 22:35
Tomas Bisciak
1,75711437
1,75711437
sir, iget the same output, null,null.
– jarnthrax
Nov 11 '13 at 22:39
yes, it works. but i want to make a new line for the next set of array. thanks @Tomas Bisciak
– jarnthrax
Nov 11 '13 at 22:41
for new line display+=array[a]+"n"
– Tomas Bisciak
Nov 11 '13 at 22:43
great! Thakn you so much guys. i hava to go now, i have 7:30 class. SALAMAT!!!!
– jarnthrax
Nov 11 '13 at 22:47
add a comment |
sir, iget the same output, null,null.
– jarnthrax
Nov 11 '13 at 22:39
yes, it works. but i want to make a new line for the next set of array. thanks @Tomas Bisciak
– jarnthrax
Nov 11 '13 at 22:41
for new line display+=array[a]+"n"
– Tomas Bisciak
Nov 11 '13 at 22:43
great! Thakn you so much guys. i hava to go now, i have 7:30 class. SALAMAT!!!!
– jarnthrax
Nov 11 '13 at 22:47
sir, iget the same output, null,null.
– jarnthrax
Nov 11 '13 at 22:39
sir, iget the same output, null,null.
– jarnthrax
Nov 11 '13 at 22:39
yes, it works. but i want to make a new line for the next set of array. thanks @Tomas Bisciak
– jarnthrax
Nov 11 '13 at 22:41
yes, it works. but i want to make a new line for the next set of array. thanks @Tomas Bisciak
– jarnthrax
Nov 11 '13 at 22:41
for new line display+=array[a]+"n"
– Tomas Bisciak
Nov 11 '13 at 22:43
for new line display+=array[a]+"n"
– Tomas Bisciak
Nov 11 '13 at 22:43
great! Thakn you so much guys. i hava to go now, i have 7:30 class. SALAMAT!!!!
– jarnthrax
Nov 11 '13 at 22:47
great! Thakn you so much guys. i hava to go now, i have 7:30 class. SALAMAT!!!!
– jarnthrax
Nov 11 '13 at 22:47
add a comment |
you could do that in 1 loop.
For example:
public static void main(String args) {
String display="";
String size = JOptionPane.showInputDialog("Enter Your Prefered Size Of Your Array");
int newsize = Integer.parseInt(size);
JOptionPane.showMessageDialog(null,"You Entered "+newsize+".");
String array = new String[newsize];
for (int a=0; a<array.length;a++)
{
array[a] = JOptionPane.showInputDialog("Enter Value For Array["+a+"].");
display = display +array[a] + "n";
}
JOptionPane.showMessageDialog(null,display);
}
}
add a comment |
you could do that in 1 loop.
For example:
public static void main(String args) {
String display="";
String size = JOptionPane.showInputDialog("Enter Your Prefered Size Of Your Array");
int newsize = Integer.parseInt(size);
JOptionPane.showMessageDialog(null,"You Entered "+newsize+".");
String array = new String[newsize];
for (int a=0; a<array.length;a++)
{
array[a] = JOptionPane.showInputDialog("Enter Value For Array["+a+"].");
display = display +array[a] + "n";
}
JOptionPane.showMessageDialog(null,display);
}
}
add a comment |
you could do that in 1 loop.
For example:
public static void main(String args) {
String display="";
String size = JOptionPane.showInputDialog("Enter Your Prefered Size Of Your Array");
int newsize = Integer.parseInt(size);
JOptionPane.showMessageDialog(null,"You Entered "+newsize+".");
String array = new String[newsize];
for (int a=0; a<array.length;a++)
{
array[a] = JOptionPane.showInputDialog("Enter Value For Array["+a+"].");
display = display +array[a] + "n";
}
JOptionPane.showMessageDialog(null,display);
}
}
you could do that in 1 loop.
For example:
public static void main(String args) {
String display="";
String size = JOptionPane.showInputDialog("Enter Your Prefered Size Of Your Array");
int newsize = Integer.parseInt(size);
JOptionPane.showMessageDialog(null,"You Entered "+newsize+".");
String array = new String[newsize];
for (int a=0; a<array.length;a++)
{
array[a] = JOptionPane.showInputDialog("Enter Value For Array["+a+"].");
display = display +array[a] + "n";
}
JOptionPane.showMessageDialog(null,display);
}
}
answered Nov 11 '13 at 22:53
Daniel Hernández
1,44731529
1,44731529
add a comment |
add a comment |
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.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- 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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f19917221%2fdisplaying-array-with-joptionpane%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
1) For better help sooner, post an SSCCE. 2) Please use code formatting for code, input/output & structured documents like HTML or XML. To do that, select the sample and click the
{}button above the messaged posting/editing form. 3) Please add an upper case letter at the start of sentences. Also use a capital for the word I, and abbreviations and acronyms like JEE or WAR. This makes it easier for people to understand and help. 4) What is your question?– Andrew Thompson
Nov 11 '13 at 22:28
You just need
JOptionPane.showMessageDialog(null,"n"+display);– Smit
Nov 11 '13 at 22:30
ahhmm, Im sorry, i'm not good in english and i didn't nos. 1-3, and for no. 4. my QUESTION is , how to display all myarrays in JOPtionPane.showMessageDialog.
– jarnthrax
Nov 11 '13 at 22:32
but sir, i get an output "nullnull".
– jarnthrax
Nov 11 '13 at 22:34
@user2981000 Thats because you are not saving your values to array. Refer to answer given by @ Tomas Bisciak
– Smit
Nov 11 '13 at 22:37