Write a program that displays following two strings: It's Windows path: "C:Program FilesJavajdk1.7.0bin" It's Java string: "C:\Program Files\Java\jdk1.7.0\bin"

public class Solution { public static void main(String[] args) { String s1="It's Windows path: "C:Program FilesJavajdk1.7.0bin""; String s2="It's Java string: "C:\Program Files\Java\jdk1.7.0\bin""; System.out.println(s1); System.out.println(s2); } } What's wrong with this code ? Please help me.

asked 07 Jun '15, 08:15

Vivek's gravatar image

Vivek
111
accept rate: 0%


System.out.println("It's Windows path: " + """ + "C:\ Program Files\Java\jdk1.7.0\bin" + """ );

    System.out.println("It's Java string: \\"+ "\""+ "C:"+"\\"+"\\"+"Program Files"+"\\"+"\\"+"Java"+"\\"+"\\"+"jdk1.7.0"+"\\"+"\\"+"bin"+ "\\"+ "\" ");
link

answered 25 Aug '16, 06:01

VitaliKIV's gravatar image

VitaliKIV
111
accept rate: 0%

System.out.println("It's Windows path: " + """ + "C:\ Program Files\Java\jdk1.7.0\bin" + """ );

    System.out.println("It's Java string: \\"+ "\""+ "C:"+"\\"+"\\"+"Program Files"+"\\"+"\\"+"Java"+"\\"+"\\"+"jdk1.7.0"+"\\"+"\\"+"bin"+ "\\"+ "\" ");
link

answered 25 Aug '16, 06:01

VitaliKIV's gravatar image

VitaliKIV
111
accept rate: 0%

This is what i wrote and is working on my project Intelij, but its not passing testing. What could it be? Thank you in advance.

(25 Aug '16, 06:02) VitaliKIV

public static void main(String[] args) {

    System.out.println("It's Windows path: " + "\"" + "C:\\ Program Files\\Java\\jdk1.7.0\\bin" + "\"" );

System.out.println("It's Java string: \\"+ "\""+ "C:"+"\\"+"\\"+"Program Files"+"\\"+"\\"+"Java"+"\\"+"\\"+"jdk1.7.0"+"\\"+"\\"+"bin"+ "\\"+ "\" ");

}
(25 Aug '16, 06:03) VitaliKIV

hey, sorry , i found the mistake by myself on firs statement, was a backspace here "C:\ Program Files\( between \ and Program Files

(25 Aug '16, 06:08) VitaliKIV
public class Solution

{ public static void main(String[] args) { String a = "It's Windows path"; String g = " "; String e = """; String k = ":"; String d = "\"; String l = "Program Files"; String h = "Java"; String j = "jdk1.7.0"; String q = "bin"; String c = "C"; String o = "It's Java string"; System.out.println(a + k + g + e + c + k + d + l + d + h + d + j + d + q + e ); System.out.println(o + k + g + d + e + c + k + d + d + l + d + d + h + d + d + j + d + d + q + d + e );

}
It`s work code
link

answered 05 Jan, 06:24

Ostap's gravatar image

Ostap
11
accept rate: 0%

Its work code:

public class Solution { public static void main(String[] args) { //It's Windows path: "C:Program FilesJavajdk1.7.0bin" // It's Java string: "C:\Program Files\Java\jdk1.7.0\bin" String a = "It's Windows path: "C:\Program Files\Java\jdk1.7.0\bin""; String b = "It's Java string: \"C:\\Program Files\\Java\\jdk1.7.0\\bin\""; System.out.println(a); System.out.println(b);

}

}

link

answered 07 Mar, 09:58

maestroukr's gravatar image

maestroukr
111
accept rate: 0%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×1

Asked: 07 Jun '15, 08:15

Seen: 916 times

Last updated: 14 Jul, 13:57

Related questions