We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- Java
- Introduction
- Java Stdin and Stdout I
- Discussions
Java Stdin and Stdout I
Java Stdin and Stdout I
+ 0 comments Hi. I'm new here. Don't know much about coding. But tried a diff way to solve the challenge. is it ok?
import java.io.; import java.util.;
public class Solution {
public static void main(String[] args) { /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */ Scanner scanner = new Scanner(System.in); String myString = scanner.next(); int myInt = scanner.nextInt(); int lastInt = scanner.nextInt(); scanner.close(); System.out.println(myString); System.out.println(myInt); System.out.println(lastInt); }
}
+ 1 comment can anyone tell me the actual code of this program
+ 0 comments import java.util.Scanner;
public class Solution {
public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int myInt = scanner.nextInt(); String myString = Integer.toString(myInt); do { System.out.println(myInt); myInt = scanner.nextInt(); myString = Integer.toString(myInt);} while (myString != "");
}}
+ 0 comments import java.io.*; import java.util.*; public class Solution { public static void main(String[] args) { /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */ Scanner sc = new Scanner(System.in); while (sc.hasNext()){ int num = sc.nextInt(); System.out.println(num); } } }
+ 0 comments Just tried an another way of solving the problem.
public class Solution { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int inputArray[]=new int[3]; for (int i=0;i<3;i++){ int a = scan.nextInt(); inputArray[i]=a; } scan.close(); for (int num:inputArray){ System.out.println(num); } } }
Load more conversations
Sort 456 Discussions, By:
Please Login in order to post a comment