473,388 Members | 1,480 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

Java equivalent of cin

I am new to Java programming and I was wondering if anyone can tell me the
java equivalent to a cin>>...; that is normally used in c++. I want to get
user input and automatically assign it to a variable. So in other words what
would be the equivant java statement of this c++ statement:

1: cout<<"Enter a number.";
2: cin>>x; //This is what I really want to know. I already know the java
equivalent of the first statement.

Jul 17 '05 #1
4 14958
"Gregory W. Ernest" <Ge*****@optonline.net> wrote in
news:KR*****************@fe10.lga:
I am new to Java programming and I was wondering if anyone can tell me
the java equivalent to a cin>>...; that is normally used in c++. I
want to get user input and automatically assign it to a variable. So
in other words what would be the equivant java statement of this c++
statement:

1: cout<<"Enter a number.";
2: cin>>x; //This is what I really want to know. I already know the
java equivalent of the first statement.


Are you looking for something like?

byte [] b=new byte[255];
System.in.read(b);

I strongly recommend that you download the J2SDK HTML documentation and
put in on your machine. You then have the complete class heirarchy
reference available to view at will.


----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---
Jul 17 '05 #2
I am new to Java programming and I was wondering if anyone can tell me
the java equivalent to a cin>>...; that is normally used in c++. I
want to get user input and automatically assign it to a variable. So
in other words what would be the equivant java statement of this c++
statement:

1: cout<<"Enter a number.";
2: cin>>x; //This is what I really want to know. I already know the
java equivalent of the first statement.


Are you looking for something like?

byte [] b=new byte[255];
System.in.read(b);

I strongly recommend that you download the J2SDK HTML documentation and
put in on your machine. You then have the complete class heirarchy
reference available to view at will.


That doesn't seem too efficient

Regards
Michael

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.841 / Virus Database: 572 - Release Date: 21/01/2005
Jul 17 '05 #3
"Sharp" <Sh***@SharpAddress.com> wrote in news:YIBId.129830$K7.120029
@news-server.bigpond.net.au:

Are you looking for something like?

byte [] b=new byte[255];
System.in.read(b);

I strongly recommend that you download the J2SDK HTML documentation and put in on your machine. You then have the complete class heirarchy
reference available to view at will.


That doesn't seem too efficient


As opposed to what? Use of a fixed length buffer? explicit necessity to
type cast the result to some other type?...what then?

IMHO, streams under java are ugly to begin with.
Jul 17 '05 #4
"Wiseguy <no***@all.com>" wrote in comp.lang.java:
"Sharp" <Sh***@SharpAddress.com> wrote in news:YIBId.129830$K7.120029
@news-server.bigpond.net.au:
Are you looking for something like?

byte [] b=new byte[255];
System.in.read(b);

I strongly recommend that you download the J2SDK HTML documentation
and put in on your machine. You then have the complete class
heirarchy reference available to view at will.
That doesn't seem too efficient


As opposed to what? Use of a fixed length buffer? explicit necessity to
type cast the result to some other type?...what then?


Perhaps "java.io.BufferedReader" might address the efficiency concern?
I wonder if "Sharp" needs to read line-by-line.
IMHO, streams under java are ugly to begin with.


Streams aren't the only thing, but then again there are many ugly
things in many languages. I think Java's Generics are even uglier, but they
will prove to be very beneficial in the long run.

--
Randolf Richardson, pro-active spam fighter - rr@8x.ca
Vancouver, British Columbia, Canada

Sending eMail to other SMTP servers is a privilege.
Jul 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

73
by: RobertMaas | last post by:
After many years of using LISP, I'm taking a class in Java and finding the two roughly comparable in some ways and very different in other ways. Each has a decent size library of useful utilities...
40
by: Eitan | last post by:
Hello, I know Java-Applet (written for JBuilder). I would like to know about dotnet technology, pros and cons in comparation to Java-Applet technololgy. Can I write a program in dotnet, like...
4
by: Jim H | last post by:
Does .NET have an equivalent to java's JMS messaging. I'm not a java programmer but as I understand it a java application can be setup to pass entire objects between processes. Is there some sort...
7
by: Mario | last post by:
I've been reading some Sun Java articles where they say Applets cannot import dlls and cannot write to disk. (This does NOT apply to applications, only to Applets.) Supposedly, this is NOT...
2
by: yaron | last post by:
Hi, for porting java to c# i need to know: What is the C#.NET equivalent for java.net.SocketAddress and java.nio.ByteBuffer ? Thanks.
28
by: liorm | last post by:
Hi everyone, I need to write a web app, that will support millions of user accounts, template-based user pages and files upload. The client is going to be written in Flash. I wondered if I coudl...
1
by: David Van D | last post by:
Hi there, A few weeks until I begin my journey towards a degree in Computer Science at Canterbury University in New Zealand, Anyway the course tutors are going to be teaching us JAVA wth bluej...
26
by: Christoph Zwerschke | last post by:
You will often hear that for reasons of fault minimization, you should use a programming language with strict typing: http://turing.une.edu.au/~comp284/Lectures/Lecture_18/lecture/node1.html I...
6
by: mearvk | last post by:
Does C++ or C have something roughly equivalent to this: http://java.sun.com/javase/6/docs/api/java/math/BigInteger.html What I need is a way to quickly convert between decimal and binary and...
5
by: Daniel | last post by:
Hi all, I have some questions regarding C#. I come from a Java background. I am using .NET 1.1. Please limit your answers to v 1.1, otherwise please state the version to which it applies to. ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.