简体   繁体   English

编写一段文本作为源代码(Java)

[英]Write a text that would be the source code (Java)

the task is:任务是:

"Write a complete Java program called Date whose output is the text that would be the source code of a Java program that prints "Introduction to Java Programming!" as its output." “编写一个名为 Date 的完整 Java 程序,其输出的文本将是打印“Java 编程简介!”作为其输出的 Java 程序的源代码。”

Dont I only have to write a single statement with "System.out.println("Introduction to Java Programming!");"难道我只需要用“System.out.println(“Java 编程简介!”);” ? ?

Or they want something else from me?或者他们想从我这里得到别的东西?

Thank you for help!谢谢你的帮助!

Your task is, to write a program in Java that itself spits out Java code, that, when compiled would spit out that sentence.你的任务是,用 Java 编写一个程序,它本身会输出 Java 代码,编译时会输出那句话。

something like就像是

 main()
 {
    System.out.prinln("main () { System.out.println(\"....

I don't know who's assigning such homework, but that's the most useless stuff I ever heard and doesn't get you anywhere in learning Java...我不知道是谁在布置这样的作业,但这是我听过的最无用的东西,并且不会让你学习 Java ......

You will need a surrounding class around your statement.您将需要围绕您的陈述进行周围的课程。

System.out.println("Introduction to Java Programming!");

And some specific method, starting with the character m , to make it work.还有一些特定的方法,从字符m ,使其工作。

You may want to look into StringBuilder class to keep your sanity.您可能需要查看StringBuilder类以保持理智。 But I wonder who assigns such stupid assignment.但我想知道是谁分配了如此愚蠢的任务。 Pointless exercise, really.毫无意义的锻炼,真的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM