Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
I'm very new to Java and I was wondering why my code wasn't running.
Is there anything I need to do or I have missed out, every time I click run the bar at the bottom is just infinitely saying "running...".
Your code is asking for a user input before logging anything, that's probably why you think it's not running.
Try to print something before like this:
System.out.println("Enter a number:");
int i = scanner.nextInt();
System.out.println("You chose " + i);
(Pseudo code)
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 15 hours ago.
Improve this question
enter image description here
I've tried googling and I have even created a chegg account but I didn't get an explanation or what I was expected to do.
What am I expected to put in the box?
What am I expected to put in the box?
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I am fairly new to Java programming and have been using a for loop in my program. I noticed whenever my program asks for user input, that whenever I press the enter key that is used as the next key for the second iteration of the loop. Is there a way to make this not occur?
Use while loop instead:
while(true){
String input = JOptionPane.showInputDialog(null, "Please enter something.");//take inputs while have not encountered STOP
if(input.equals("STOP")){
System.exit(0);
}
}
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
Example
if there are 4 slots named A1,B1,C1,D1. If first user enters A1 and when the second user enter the same slot it should error it has already been chosen.
The built-in class java.util.HashMap can do that. Read the docs, perhaps search for some usage examples :)
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
Hi I am new to Java and I wanted to learn how to make one program that will create accounts that will be stored in a file in the file of the code and then later you can access it to enter and go to a main program to do something else, I passed all day looking for but everyone using GUI so I do not see the code and it doesn't work well so I wanted to ask to people from here thank you in advance
You can use the Scanner library, which will download text from the console.
Sample part of the program
Scanner download = new Scanner (System.in);
String login = download .nextLine ();
In the login variable, you store the String entered in the input;)
More information :
https://docs.oracle.com/javase/tutorial/essential/io/
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I want a program for printing numbers in below format in java.
for(int i=0,r=1;i<h.length/2;) {
//System.out.println(h[i]);
for(int j=i;j<r;j++) {
System.out.print(h[j]);
}
System.out.println("");
r=r+2;
}
The expected output should be
1
24
356
System.out.println("1\n\n24\n\n356");
</sarcasm>
more information is needed (what is your exact problem? what do you want to achieve? input -> outcome)
what have you tried and where exactly are you stuck.
Edit your question and i edit my answer ;)