Java Programming Tutorial 36 - Array Values from Input with for Loop

preview_player
Показать описание


~~~~~~~~~~~~~~~ CONNECT ~~~~~~~~~~~~~~~

~~~~~~~~~~~~~~ SUPPORT ME ~~~~~~~~~~~~~~

🅑 Bitcoin - 3HnF1SWTzo1dCU7RwFLhgk7SYiVfV37Pbq
🅔 Eth - 0x350139af84b60d075a3a0379716040b63f6D3853
Рекомендации по теме
Комментарии
Автор

my final is around the corner, thanks for making these videos, its awesome, HELPS ALOT!! THANK YOU

janrauhl
Автор

for(int i=0; i<size; i++) {
System.out.print(grade[i] + ", " )
}

sutriptimnath
Автор

Instead of int x = input.nextInt();
grades[i] = x;


You could just do grades[i] = scanner.nextInt();

LimeWitness
Автор

for (int i = 0; i < size; i++) {

}

zahraxhamzah
Автор

for(int i = 0; i < size; i++) {
System.out.print(input[i] + " ");

}


hooray! And thanks so much Caleb. I've watched all videos so far. You're really helping me get a head start before I start a software development course next month.

mauriceallenliddy
Автор

Hey, thanks for making these vids, helps ALOT!

BeastReview
Автор

thanks! very helpful, my assignment is finished :)

muhammadsyamsul
Автор

Firstly, this is great content. Thank you for these videos!!!

I added some statements to aks for input. Also, I used grades.length to print out the array using a for loop.
Not sure if it's the best option.

import java.util.Arrays;
import java.util.Scanner;



public class MySweetProgram {

public static void main(String[] args) {
System.out.println("Choose the size of the Array.");
Scanner input = new Scanner(System.in);
int size = input.nextInt();
int[] grades = new int[size];

for(int i = 0; i < size; i++) {
System.out.println("Insert a digit.");
int x = input.nextInt();
grades[i] = x;
}

for(int k = 0; k < grades.length; k++) {
System.out.print(grades[k] + " ");
}

}
}

ZiJoe
Автор

For the solution to the last part, I put the last statement within the for loop and it's printing each element as it's added to the array.
Not sure if this was what you wanted us to do, if not could you please explain.

nik
Автор

Finally A video with 0 dislike. He deserves it too.

chasechicken
Автор

Had to actually look it up... forgot to put corner brackets around i

-> will give you that value of the arraynumber based in the run-variable from the For-loop

Lutscherstange
Автор

what about if you create a array directly from user input. Like read number to array until user input negative number (positive numbers should be the size of array). How this works?

elmua
Автор

for outputting array without using the toString I did:

public static void arrayToString(int[] Array) {

for(int i = 0; i < Array.length; i++) {
if(i == (Array.length - 1)){

System.out.println(Array[i]);

} else {

System.out.printf(Array[i] + ", ");

}

} //End of arrayToString


And in my main method:
arrayToString(grades);
I guess I'm a bit late to this.

TechJoltd
Автор

I was wondering is it possible to use it in string arrays?

zy
Автор

on windows it lets me input integers but doesn't show anything, and it only has a yellow underline under our name for the scanner. when hovering over it, it says scanner cannot close.

ShawnJeezie
Автор

Hi, I know its been years since you did this video and I am now learning java. Can you explain why line 13 is there and what is does. Please

nanaarhin
Автор

how do you do loop for names like usernames?

tatimore
Автор

Caleb! I want to ask you questions can i email to you?

a_nurulasyiqin
Автор

What about ArrayList with a for loop user input!!!!

herevancelightena
Автор

Why don't you use sout instead fo sysout?

BaconAndMinecraft