I am trying to do this task in IntelliJ and it will not work correctly. On the website it already has the list of names but in IDE it doesnt have it attached. How can you work/run a program in the IDE if you dont have all the tools for the program in the plugin?
how do you get this to run in IntelliJ?
Under discussion
Comments (17)
- Popular
- New
- Old
You must be signed in to leave a comment
Thomas
16 July 2022, 06:44
What names? From the two lines I can read from the task description it asks to create an array, enter 10 numbers (not names, no list) and then output the array in reverse order.
Please post code so that we can see your problem.
0
Cronox79
16 July 2022, 11:53
Create an array of 10 strings.
Enter 8 strings from the keyboard and save them in the array.
Display the contents of the entire array (10 elements) on the screen in reverse order.
Each element on a new line.
Requirements:
• The program should create an array and initialize it with new String[10] value.
• The program should read 8 strings for the array from the keyboard.
• The program should display 10 strings on the screen, each on a new line.
• The program should display the array (10 elements) in reverse order.
Thanks for getting back to me Thomas. I was trying to do this one on IntelliJ but it was not reading in the names. I haven't tried to do the one for the numbers yet because I think that it will do the same thing.
0
Cronox79
16 July 2022, 12:08
this is the task for the numbers...
Array of numbers in reverse order
Create an array of 10 numbers.
Enter 10 numbers from the keyboard and write them to the array.
Display the elements of the array in reverse order. Display each value on a new line.
Requirements:
1. The program should create an array and initialize it with new int[10] value.
2. The program should read numbers for the array from the keyboard.
3. The program should display 10 values, each on a new line.
4. The array must be displayed in reverse order.
0
Thomas
16 July 2022, 12:15
And what's the code you have written? When you create a question there's a switch that lets you attach your code and the requirements automatically.
0
Cronox79
16 July 2022, 12:58
the code I wrote in IntelliJ is:
package en.codegym.task.jdk13.task07.task0702;
import java.io.BufferedReader;
import java.io.InputStreamReader;
/*
String array in reverse order
*/
public class Solution {
public static void main(String[] args) throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String[] array = new String[10];
for (int i = 0; i < 8; i++) {
array[i] = reader.readLine();
}
for (int i = 9; i >= 0; i--) {
System.out.println(array[i]);
}
}
}
0
Cronox79
16 July 2022, 12:59
this will work in CodeGym but will not run on IntelliJ
0
Thomas
16 July 2022, 13:20
OK, your code runs perfectly in my IntelliJ... so is this the first time you try to use IntelliJ?
Can you create a new project and compile a hello world System.out.println()
Do you have a JDK installed?
What's IntelliJ telling you. What's the error msg, what does not work... compiling?
0
Cronox79
16 July 2022, 13:33
wow! lots of question. lol. I am using IntelliJ 64 version 1.8 (I have version 16 available but for school we are using 1.8) I have a lot of programs saved from school and yes I can create "Hello World!". lol. The JDK is installed. There are no errors it gives me the console display wanting an input but when I enter anything into the console it immediately puts it into the same console window.
If I switch the code from the import statements: import.java.io.BufferedReader and ImportStreamReader to a scanner I believe it should allow my program to accept the inputs but I dont know if that will be acceptable to pass what the CodeGym is looking for.
What are your thoughts on this?
0
Thomas
16 July 2022, 13:46
;) getting closer
With 1.8 and 16 you probably mean the JDK versions you're using or the featureset you allow inside the JDK. The actual IntellijJ version is IDEA 2022.1.3 and I suggest to upgrade. I remember a bug a few weeks ago that made it impossible to work with the reader class inside a loop. As a workaround it was possible to add a sout after a read(Line) call. But of course that won't validate. This just lets you test your code.
The June update made that work again.
0
Cronox79
16 July 2022, 13:55
good to know. I am updating my IntelliJ right now so I might be offline here in a min or so. I just did an update a few days ago but it wasn't 18. I just saw 18 today...
0
Thomas
16 July 2022, 14:18
I'm talking about updating IntelliJ, not the JDK. In IntelliJ: Help -> Check for updates
For the JDK... I'd use 17 as this is a LTS version
0
Cronox79
16 July 2022, 14:26
yes. that is where I went. I in the upper right hand corner there is an icon that indicates that there is an update available. I went to it and clicked on it and it allows me to update any update available. I did that and it updated the JDK to 16 then it showed that the 17 was available so I did that one as well. Just now it showed that 18 was available so I am doing it right now. when you update does it automatically update the code you are currently running or do you have to manually have to switch?
0
Thomas
16 July 2022, 14:31
I have several JDKs installed. But IntelliJ needs to be updated to IDEA 2022.1.3 (you can check this in Help - About). If you're running the latest version and not 2022.1.2 then you have some different problem than I had in mind.
0
Cronox79
16 July 2022, 14:43
Ok. everything is up to date. it says 2022.1.3 (Community Edition). and now it works. thank you so much. I know its late there and you were a great help. :) thanks again. hope to see you on here again.
0
Cronox79
16 July 2022, 14:45
would you be ok if I add you to friends list? You would be my first one!
0
Cronox79
16 July 2022, 14:47
just ran it here is the output from the console.
grandfather
grandmother
father
mother
son
daughter
cat
dog
null
null
dog
cat
daughter
son
mother
father
grandmother
grandfather
0
Thomas
16 July 2022, 15:15
I'm glad it works for you now ;)
0