Bug 543105 - printf change line exception
Summary: printf change line exception
Status: ASSIGNED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Debug (show other bugs)
Version: 4.2.1   Edit
Hardware: PC Windows 10
: P3 normal with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: JDT-Debug-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2018-12-31 22:42 EST by Yuan Yuan Chen CLA
Modified: 2023-01-22 17:09 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Yuan Yuan Chen CLA 2018-12-31 22:42:40 EST
public static void main(String[] args) {
		System.out.print("@12");
		///可以在输出参数后面加\n来换行
		System.out.print("@123\n");
		
		///也可以在输出参数(或者变量)后面加上+"\n"来换行
		System.out.print("@1231"+"\n");
		
		System.out.printf("%s","@1234");
		
		///可以在格式化输出类型后面加\n来换行
		System.out.printf("%s\n","@12345");
		
		///可以在格式化输出类型%n来指定输出一行,其效果等同于println
		System.out.printf("%s%n","@123451");
		System.out.printf("%s%%","null@123451");
		System.out.println();
		System.out.printf("++++++输出%%%"+"nullnull$"+".2"+"fd:"+"  %1$.2f ",2019.0101);
		
		///也可以在输出参数(或者变量)后面加上+"\n"来换行
		System.out.printf("\n"+"%s","@123456"+"\n");
		
		///println()相当于printf(\n\n),即另起一行输出对应的参数后,再进行一次换行
		System.out.println("@1234567");
		// TODO Auto-generated method stub

	}

}
output:
@123451
null@123451%
++++++输出%
ullnull$.2fd:  2019.01 
@123456
@1234567
Comment 1 Yuan Yuan Chen CLA 2018-12-31 22:46:48 EST
	System.out.printf("%s%%","null@123451");
output:
null@123451%
And why did there hava a "%"?
But
	System.out.printf("++++++输出%%%"+"nullnull$"+".2"+"fd:"+"  %1$.2f ",2019.0101);
output:
++++++输出%
ullnull$.2fd:  2019.01
If it is right,what is the rule?
Comment 2 Eclipse Genie CLA 2020-12-21 12:16:39 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 3 Sarika Sinha CLA 2020-12-22 23:48:40 EST
@Paul,
Do you want to have a look at this?

System.out.printf("%s%%","null@123451");
output:
null@123451%
Comment 4 Eclipse Genie CLA 2023-01-22 17:09:21 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.