English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I am more familiar with C# where I would:

Console.Writeline("{0}, {1}", variableOne, variableTwo);

(Or something very similar) What is the equivalent in Java?

Thanks for your help!

2007-08-23 09:00:12 · 2 answers · asked by narsilshard 1 in Computers & Internet Programming & Design

2 answers

The equivalent in Java would be:

System.out.println("" + variableOne + ", " + variableTwo);

You can just use "+" for String concatenation. As long as the leftmost part of the expression is a String (which is why I put an empty-string in front of variableOne), it will work.

There are also ways to do formatted output, but they're not generally necessary unless you're trying to get columns to line up, or print floating-point numbers to a specific number of decimal places.

2007-08-23 09:36:21 · answer #1 · answered by McFate 7 · 1 0

Java Print Integer

2016-10-20 06:41:40 · answer #2 · answered by ? 4 · 0 0

Code in c++ is as below #include #include void main() { clrscr(); cout<<"Enter two integers:'; int a,b,count; cin>>a>>b; if(a>b) { int c=a; a=b; b=c; } for(int i=a;i<=b;i++) { if(i%3==0) count++; } cout<<"Number of multiples of three between"<

2016-03-13 00:20:44 · answer #3 · answered by Anonymous · 0 0

fedest.com, questions and answers