㈠ 怎么在eclipse java中控制台输出
第一步:在菜单栏window下拉菜单中的”show view“中找到”Console“打开并拖拽到eclipse工具内的适当位置。
第二步:在java代码中增加类似于”System.out.println()“方法,并在println方法中增加合适的参数值”success“(根据实际情况输入要输出的内容)。
第三步:在java类(含有main方法)中,右击”run as“,选择”java Application“运行即可实现控制台内容输出,效果如图,”success“已经打印在控制台中。
㈡ java中从控制台让用户输入参数的语句是什么
首先,java.util.Scanner包中的Scanner(中文意思是扫描仪)类,这个类是一个final类继承于object类,从它的类名上就可以看出它有点类似于扫描仪,所以它只能扫描用户输入到屏幕上的信息,这是就需要一个System.in然后再扫描(我是这样认为的)。当然它扫描到的只是字符,但在需要时可以转换成其他类型,它提供了很多此类的方法:String next()、 BigDecimal nextBigDecimal() 、BigInteger nextBigInteger() 、BigInteger nextBigInteger(int radix) 、 boolean nextBoolean() 、byte nextByte() 、 byte nextByte(int radix) 、double nextDouble() 、float nextFloat() 、int nextInt() 、int nextInt(int radix) 、 String nextLine() 、long nextLong() 、long nextLong(int radix) 、short nextShort() 、short nextShort(int radix) 。这些方法都可以得到相应类型的数据。例如:import java.util.Scanner;public class Importtext {public static void main(String[] args) {Scanner sc = new Scanner(System.in);int i = sc.nextInt();System.out.println(i);}}
㈢ java 中怎么从控制台读取参数例如输入 circle,x=12,y=3,r=4 要提取x,y,r的值
import java.util.*;
import java.io.*;
public class TestPrintWriter {
public static void main(String[] args) {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
FileWriter fw = null;
PrintWriter pw = null;
try {
fw = new FileWriter("E:\\java\\io\\6.txt",true);
pw = new PrintWriter(fw,true);
String s = null;
while ((s=br.readLine()) != null) {
if (s.equals("exit")) {
break;
}
System.out.println(s);
pw.println(s);
}
pw.println(new Date());
}catch (IOException e) {
e.getMessage();
e.printStackTrace();
}
finally {
try {
br.close();
}catch(IOException e) {
e.getMessage();
e.printStackTrace();
}
pw.close();
}
}
}
㈣ Java控制台打印出主函数所传入的参数
在Eclipse的平台下,是没有东西显示的。
但在cmd命令提示符是可以运行的。
㈤ JAVA关于字符串、数组、赋值、控制台输入参数传值
1:
String[] s1={"sdfefe","fesadc","vdewsc","dedads"};
int x=s1.length;
int y=0;
for(int i=0;i<s1.length;i++){
if(s1[i].length()>y){
y=s1[i].length();
}
}
//声明二维数组
String[][] s2=new String[x][y];
for(int i=0;i<s1.length;i++){
for(int j=0;j<s1[i].length();j++){
//给二维数组赋值 i=0,j=0时,值为"sdfefe"中的‘s‘ 类推下去=0,j=1时为'd' 类推
s2[i][j]=""+s1[i].charAt(j);
}
}
2:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Test {
/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String str = null;
System.out.println("Enter your value:");
str = br.readLine();
//输入123456789
//创建数组
int length=str.length();
int[] numbers=new int[length];
for(int i=0;i<length;i++){
//给数组赋值
numbers[i]=(int)str.charAt(i);
}
}
}
㈥ java怎么获取控制台输入的数据
//构造一个Scanner对象scanner,利用System.in作为构造参数
Scanner input= new Scanner(System.in);
//利用scanner中的方法获得用户的输入
input.next()--获取版字符串对象权
input.IntNext()--获取整数数值对象
㈦ java 在控制台输入一些参数,直到输入quit推出输入,然后把输入的内容显示出来。
import java.util.Scanner;
public class QuitToOut {
public static void main(String[] args){
Scanner input = new Scanner(System.in);
String enter; // 输入的信息变量
boolean answer = true; // 循环条件
while(answer){
System.out.print("Please send your message:");
enter = input.next();
if(enter.equals("quit")){
answer = false;
System.out.println("Good bye!");
// 这里也可以用 break 直接跳出
}
}
}
}
㈧ java method从控制台获取args参数
可以看到,man(String[] args):所以args是属于数组,所以设置类型为数组就好:
argstest(String[] arr),调用的时候同样传入数组args
望采纳