一道有趣的Java编程题,如何输出Hello world!

作者&投稿:彭殷 (若有异议请与网页底部的电邮联系)
一道有趣的Java编程题,如何输出Hello world!~

……v_v……

System.out.append("hello")
==
null
append代表在printStream加上输出。
这回该我的答案该通过了吧?再不通过我就贴到空间上去。

可以这样:

public class Demo {
    public static void main(String... a) {
        if (new Object() {{System.out.print("Hello,");}} == null) {
            System.out.print("Hello,");
        } else {
            System.out.println("World");
        }
    }
}

输入结果:



public class HelloWorld{
public static void main(String[] args){
System.out.println("Hello,the World!!");
System.out.println("这是我编写的第一个Java程序!");
}
}

if(System.out.append("Hello")="")

class MyTest{
public static void main(String[] args){
try{
if(System.out.append("Hello ")==null){
System.out.print("Hello ");
}else{
System.out.println("world!");
}
}catch (Exception e) {
e.printStackTrace();
}
}
}

楼主意思是输入第一个句子和第二个句子的内容是吧?而不是“helloworld”对吧?
想不出来


Java中常见的30道例题(附代码)
Java编程中,以下是一系列常见的例题及其代码示例:1. 题目一:计算数组中奇数和偶数的个数并求和。通过遍历数组,判断每个元素的奇偶性来实现。2. 题目二:在三个数中找出最大值,通常使用if-else或三元运算符进行比较。3. 题目三:筛选并打印特定数据,通过条件判断过滤数组元素。4. 题目四:输入0...

2道JAVA编程题,等高手
第一题:1 输入一行字符,分别统计出其中英文字母、空格、数字和其他字符的个数。代码如下:import java.util.*;public class Ss { public static void main(String[] args) { Scanner input=new Scanner(System.in);System.out.println("请输入字符串:");String myString=input.nextLine();int l...

3道java编程题,求解
package TestPerson;\/** * (1) 编写程序实现如下功能:已知Person类包含三个公共成员变量(姓名、性别、年龄)和一个构造方法, * Student类是Person类的派生类,包含两个新的公共成员变量(学号、班号)、两个公共方法(修改年龄、显示基本信息)及一个构造方法。 * 在测试类Test1中,定义一组学生对象...

用Java编程两道简单的题回答出来追加悬赏
第一道不明白你的意思 第二道看代码 Random random = new Random();int min = Integer.MAX_VALUE;int max = Integer.MIN_VALUE;\/\/随机产生总共要随机的数量 (我内存不够大,这里我限制了最多100个)int length = random.nextInt(100);int[] ranArr = new int[length];\/\/产生所有随机数 ...

这道java编程题,希望会的人解答。
1、代码如下 package BaiDdu;public class Test {public static void main(String[] args) {\/\/int a=1,b=5,c=4;int a=1,b=4,c=8;float delta=b*b-4*a*c;if ( delta>0) {float r1,r2;r1=(float)(-b+Math.sqrt(delta))\/2*a;r2=(float)(-b-Math.sqrt(delta))\/2*a;...

急求几道java编程小题,望各位大神解救!
public double getNum(double x){ return Math.exp(x-1)*Math.cos(Math.PI\/x); }好我来再做一道

几道java的编程题
public class Sum { public static void main(String[] args) { int sum = 0;for(int i=1;i<=100;i++){ if(i%3==0){ \/\/如果是3的倍数加起来 sum = sum + i;} } System.out.println("1到100之间3的倍数之和是:"+sum);} } (2)public class GCD { public static void ...

各位大哥帮帮忙,4道JAVA编程题(英文的)
1:public class ComputerAccount{ private String realName,userName,password ;ComputerAccount(String realname,String username,String password){ this.realName = realname;this.userName = username;this.password = password;} public void printRealName(){ System.out.println("printRealName"+this...

100分,几道简单的Java编程题,帮忙解决一下!
以前有过类似的练习 修改了一下就发了 我也同意楼下的观点 自己动手做一下 有什么不明白的可以参考我的这个 也许你有更好的解决方法 1.import java.util.Scanner;public class Test_If_Switch { public static void main(String[] args) { System.out.println("输入一个数字:");Scanner sc =...

5道简单的JAVA编程题(高分悬赏)
编写完程序的后缀名是.java,如本题,文件名就是One.java。开始\\运行\\cmd,进入“命令提示符窗口”,然后用javac编译器编译.java文件,语句:javac One.java。(3)编译成功后,生成的文件名后缀是.class,叫做字节码文件。再用java解释器来运行改程序,语句:java One 2、编写程序,输出1到100间的...

林芝地区17020474964: 一道有趣的Java编程题,如何输出Hello world! -
张璧烧伤: ……v_v…… System.out.append("hello") == null append代表在printStream加上输出. 这回该我的答案该通过了吧?再不通过我就贴到空间上去.

林芝地区17020474964: java编程题,输入一个正整数,按如下形式输出 -
张璧烧伤: public class TestPrint {public static void main(String[] args) {Matrix m = new Matrix(15);m.compute();System.out.print(m); } }class Matrix {private enum Direction {LEFT, RIGHT, UP, DOWN}; int rowCount;int[][] data; public Matrix(int ...

林芝地区17020474964: 求一道JAVA编程题 利用循环在屏幕上输出 * ** *** **** ***** 谢谢额 -
张璧烧伤: public class Test{ public static void main(String[] args) { for(int i=1;i<6;i++){ for(int j=1;j<=i;j++) System.out.print("*"); System.out.print(" "); } } }

林芝地区17020474964: java 编程小题 (逆序输出) -
张璧烧伤: 额,又这个题目..String str; Scanner scan=new Scanner(System.in); str=scan.nextLine(); str=(new StringBuffer(str).reverse()).toString(); System.out.println(str);

林芝地区17020474964: 这道题目怎么做啊???急 Java编程:使用循环语句输出如下图案(菱形) * *** ***** ******* ***** *** -
张璧烧伤: static private string x = "*"; static private string k = " "; public static void main(string[] args) { drow(4); } public static void drow(int hang) { for (int i = 1; i for (int j = 1; j system.out.print(k); } for (int k = 1; k system.out.print(x); } system.out.println(); } for...

林芝地区17020474964: java牛客编程题输入输出怎么写 -
张璧烧伤: 根据主函数来看,你每次输入都需要通过点击确认,程序才能继续运行,count(num)函数才能调用.然后就需要根据你的题目要求来看是否是允许多次输入.

林芝地区17020474964: 一道java 文件输入输出 的编程题 -
张璧烧伤: 就是输入5个0 到100的数然后存入文件嘛.代码如下:import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.util.Scanner; public class Test { public static void main(String[] args) { Scanner sc = new Scanner(System.in);...

林芝地区17020474964: 求大神帮我讲解下这道java 编程题.题目如下.另外再打印输出一个等腰三角形.外加一个直角三角形. -
张璧烧伤: for (int row = 0; row < 5; row++) { for (int col = 1; col <= 2 * row - 1; col++) { System.out.print("*"); } System.out.println(); } System.out.println("正的直角三角形"); System.out.println("-------------------------------------------------"); for (int row = 0; row ...

林芝地区17020474964: 求解一题JAVA编程题:输出以下图形:
张璧烧伤: public class ggyy { public static void main( String[] args ) { for ( int i = 0; i < 5; ++i ) { for ( int j = 0; j < 6; ++j ) System.out.print( "*" ); System.out.println(); } } }

林芝地区17020474964: 请教JAVA编程题“编程实现反转一个字符串并输出” -
张璧烧伤: StringBuffer的常用方法 这个方法返回字符串缓冲区的当前容量.public synchronized StringBuffer reverse() 这个方法反转字符串缓冲区中的字符串 public int length() 这个方法返回缓冲区中字符的个数 public synchronized setLength(int newLength) 这个方法设置字符串缓冲区的长度.public synchronized charAt(int index) 这个方法返回字符串缓冲区中指定位置的字符 这个方法将字符串缓冲区中指定位置的字符设置为ch.

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 星空见康网