J
Jeff Higgins
For example using less abstractions and less involve with Java
stream class hierarchy.
For a beginner, learning to write C in Java is unhelpful.
For example using less abstractions and less involve with Java
stream class hierarchy.
As you said, may be the concepts behind them are complex (I don't-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Le 19/06/2011 15:44, Saeed Amrollahi a écrit :
Yes, indeed, i did a mistake.
Replace the .print( with a .println(, othewise output is not flushed and
the greeting appear only after output.
Now it OK.
Our Câºâº version *seems* simplest, but concepts behind >> and << are very
complex and can be very dangerous (overriden operator).
It's not dangerous. but my answer: use '\n' rather than std::endl;And in your code, I don't no if you know the difference, but std::endl
is very very dangerous. It's not just equal to EOL but also flush the
buffer.
BTW, thank you for your insightful answers.This bad shortcut lead to very poor i/o performances in most of
applications, all outputs flushing continuously buffer instead just send
EOL.
All of those considered, Câºâº code is the shortest but notthe simplest =)
What language does the beginner wish to learn?
You are right.Sun, 19 Jun 2011 06:06:17 -0700 (PDT), /Saeed Amrollahi/:
public static void main(String[] args) throws IOException {
System.out.print("Please enter your first name: ");
String name = new String();
Reader r = new InputStreamReader(System.in);
for (char ch; (ch = (char)(r.read())) != '\n'; name += ch) {}
System.out.println("Hello, " + name);
}What are the problems of my code and how can I write
a better one. Please throw some light.
You don't need to initialize 'name' with a 'new String()' - just
assign it with an empty string literal which is a constant:
String name = "";
I try to compare C++ and Java from point of programming view.
Well, in the case of C++ code, I have to
explain cin, cout, string and two overloaded operators:>> and<<
in the case of java one: I have to
explain, the stream class hierarchy, InputStreamReader,
BufferedReader,
in, string, new operator, final, the meaning of buffered,
readLine, ...
I believe the C++ code is simpler for a beginner.
Joshua Cranmer said:C++ stack constructed-objects, references, #include (trust me, beginners
can get very confused about #include, as simple as it looks), and
And, naturally, any talk of C++ being simpler becomes hard to stomach
The new C++ standard has more than 1300 pages, but this is
base on the C standard with more than 500 pages. These are
nearly 1900 pages of a text in a condensed technical
language, yet the language does not allow to access a
directory of the filesystem or a socket of the network.
Joshua Cranmer said:C++ stack constructed-objects, references, #include (trust me, beginners
can get very confused about #include, as simple as it looks), and
And, naturally, any talk of C++ being simpler becomes hard to stomach
10 INPUT "Please enter your first name: "; N$
20 PRINT "Hello, "; N$; "!"
30 END
Nasser M. Abbasi said:name = InputString["Name?"]
Print["Hello "<>name];
Nasser M. Abbasi said:name = InputString["Name?"]
Print["Hello "<>name];
... and to do this in JEE, just follow precisely these
50 pages:
http://download.oracle.com/javaee/6/firstcup/doc/firstcup.pdf
(Ok, actually it reads the birthday date of the user and
then outputs two lines of info about the age of the user,
but this is still similar in spirit to the above program.)
10 INPUT "Please enter your first name: "; N$
20 PRINT "Hello, "; N$; "!"
30 END
Actually C++ is just a language not a complete system.-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Le 19/06/2011 21:06, Saeed Amrollahi a écrit :
In this case, do not just compare language each others, but also related
tools.
Maven or Graddle are must have in the Java World, or other tools like
Jenkins, Sonar?
Java is not just a language, it's a World. It most important part is
also community and tools.
Joshua Cranmer said:In the hq9ni language, it's even easier:
I am going to prepare a seminar under the title: C++ vs.
Java
I try to compare C++ and Java from point of programming view.
Actually, I am going to prepare a seminar under the title: C++ vs.
Java
I try to compare C++ and Java from point of programming view.
You seem sincere but I can't help wonder:
Who is the intended audience? What is the goal?
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Le 19/06/2011 15:44, Saeed Amrollahi a écrit :
And in your code, I don't no if you know the difference, but std::endl
is very very dangerous. It's not just equal to EOL but also flush the
buffer.
This bad shortcut lead to very poor i/o performances in most of
applications, all outputs flushing continuously buffer instead just send
EOL.
For a beginner, learning to write C in Java is unhelpful.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.