Questions tagged [println]

In programming, `println` generally prints out the arguments given, then moves to a new line for subsequent output.

In programming, println generally outputs the arguments supplied, then moves to a new line for any further output operations. For example, in Java you could write the following:

System.out.print("Hello ");
System.out.println("World");
System.out.println("Goodbye");

And the console would output (with \n representing newline characters):

Hello World\n
Goodbye\n

There are several languages that use the println() method; Others have different syntax that accomplishes the same functionality.

617 questions
-3
votes
1 answer

Java: Align Strings in List around the central word

I have an arraylist that contains 3 Strings. ArrayList sentences = new ArrayList(); sentences.add("it would be for his happiness and having some feelings himself"); sentences.add("a plan to…
Steve
  • 77
  • 1
  • 11
-3
votes
4 answers

Why doesn't a character increment in System.out.println()?

char char1 = 'a'; System.out.println(char1); //prints char 1 System.out.println(char1+1); //prints char 1 System.out.println(char1++); //prints char 1 System.out.println(char1+=1); //prints incremented char1 char1 += 1; …
Daniel B.
  • 1,254
  • 1
  • 16
  • 35
-4
votes
1 answer

Pls help me, how can I make the code printout the full details of the address as an output instead of empty output

/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package addressname; /** * * @author MY PC */ public class…
-4
votes
2 answers

how does recursion method helps in printing array

void printarray(int i) { if (i == 0) { return; } else { printarray(i - 1); } System.out.println("[" + (i - 1) + "]" + values[i - 1]); } Its a program that prints the array using recursion. Can anybody tell me how…
arunoday singh
  • 222
  • 2
  • 13
-4
votes
2 answers

passing two parameters to println in java

public void showOver(char x, int v){ System.out.println(x,v); } } I have try to pass x and v to "Println" like above and I've got an error why?
-4
votes
1 answer

how to make two number and text on same line

okay so i cant seem to get the variable "mChoc" and "fChoc" on the same line as "you should eat" and "chocolate bars if you are male/female to maintain your weight." could i get some help. ive been reading all over my text book and cant seem to find…
-4
votes
2 answers

Why is every System.out.println I do failed?

Every System.out.println I do fails with multiple errors. I am trying to have an input for 5 integers with "Please enter 5 integers" showing up. here is what I have. import java.util.Scanner; public class SimpleMath { public static…
Jay
  • 5
  • 1
-4
votes
2 answers

How to read a file, Split the contents and print it?

i have a file named "file" which is a text file(the file contains 1,2,3,4 integers).. Now i want to read this file and split the values in the file and print each value in new line. How can i do that??
-4
votes
4 answers

Shorter version of Java System.out.println()

Is there a way to shorthand System.out.println() as a method? System.out.println() = short(); So I could change this main method to... package Array; import java.util.Random; public class Array { public static void main(String args[]) { …
Roger
  • 3,226
  • 1
  • 22
  • 38
-5
votes
2 answers

Java program show Irrelevant output

I was doing simple java programming.But I couldn't find why my code doesn't show exect output.It should print the sqrt of given number but the output is 0. import java.lang.*; class Calculator{ double i; double x=Math.sqrt(i); } public…
-5
votes
1 answer

How can use println java in android?

How can use println java in android ? I want to use println java in android textview need a tetxview autobricker in loop public class p_00 { public static void main(String[] args) { Random rd = new Random(); rd.nextInt(101); …
Omid
  • 21
  • 1
  • 6
-5
votes
2 answers

java difference between system.out.println() and println()

I was wondering if there was a difference between these two e.g. System.out.println("Hello World"); and println("Hello World"); I know they print the same thing, but is there anything different? (I'm new to java, so I don't know so far) In other…
Randy Huang
  • 113
  • 1
  • 3
  • 11
-5
votes
1 answer

Print a for-loop, Java

I'm trying to learn java on my own. I am now re-doing some programs I've done before, but in a different way. Now I am stuck with a for-loop. I have the following code: public class Head { public static void main(String[] args) { int a = 0; …
JJ72
  • 62
  • 9
-6
votes
1 answer

How do i format a ArrayList for printing?

I want to print a Array in a specific order but i have no idea how, google is not helping me either. Output: [PR001, Slinger 6.20, 135, 380, PR002, Strip 1.07, 93, 470, PR003, Hal, 301, 965, PR004, Zolder, 23, 679] Expected output: PR001 Slinger…
user3190748
  • 55
  • 1
  • 4
-6
votes
2 answers

How do I recall code in java without rewriting it?

Say I have allot of code like.. " System.out.println("This is code"); System.out.println("This is code"); System.out.println("This is code"); System.out.println("This is code"); " This same code keeps coming up in my program…
Ammar
  • 19
  • 1
  • 1
  • 2
1 2 3
41
42