Introduction: Programming Lesson 5
Today I decided to do java and some harder batch. The programming we will learn today is player input we will start with java input.
Step 1:
first thing we need to know is that java is not object oriented programming so to program with it we need to import something.
this something is shown below.
import java.util.Scanner;
public class hipacman {
public static void main(String[] args) {
This is how it should look.
Step 2:
The next step is to get input now that you have imported the scanner. To get input you must make a new scanner the scanner can be made like this.
input = new Scanner(System.in);
String instructs = input.next();
System.out.println(instructs);
input.close();
This code will make a scanner. that copies something that the player writes.
Step 3: Batch Input
to get batch input the code below is used.
set /p input=(anything you want)
Step 4:
to make a very simple batch input copier you would use this code.
set/p input=enter
if %input% == %input% echo %input%
this code would mean if the input was input write the input an easier way is to write this
set /p input=enter
echo %input%
(remmember) pause;
hope you liked it
please fav,follow and subscribe to my youtube channel.
5 Comments
9 years ago
I looked java up in wiki and it said java was object oriented but without a scanner java cannot be used for object oriented programming. The scanner which java gives can be obtained by writing import java.util.Scanner the scanner is given with java so you can let the person write text into the screen if this comment helped please message me
Reply 9 years ago on Introduction
You are getting closer, but the import has nothing to do with java being OO or not. Google the java import statement, pretty much all it does is let you use unqualified names, which is the way you have choose to reference it. There are other ways.
9 years ago
actually java is not object oriented. And it is necessary to import. without importing you would not be able to make the scanner. The scanner allows someone to write text in the program. The program then uses the scanner to because the scanner has been put in the system. The scanner is object oriented programming. The reason why we import is because java is not object oriented. The scanner is an object if this message did not help I can try to make an instructable just about what i am doing
Reply 9 years ago on Introduction
I have programed in java for years, but do not just take my word for it, wikipedia says in the first sentence on java:
"Java is a computer programming language that is concurrent, class-based, object-oriented, and specifically designed to have as few implementation dependencies as possible. "
As for imports try running:
**
* The HelloWorldApp class implements an application that
* simply prints "Hello World!" to standard output.
*/
class HelloWorldApp {
public static void main(String[] args) {
System.out.println("Hello World!"); // Display the string.
}
}
9 years ago on Introduction
Could you tweak up the first sentence, it may put some people off as:
Java is object oriented
It is common to import but not necessary
Finally you might explain what a scanner is up front so people know what you are trying to achieve.