public class SolEscape {
public static void main(String[] args) {
SolEscape solescape = new SolEscape("Dinesh");
System.out.println("This is Escape Sequence Example " + solescape);
System.out.println("This is Escape Sequence Example " + solescape.toString())
}
}
Error actual and formal argument differ in length..
Under discussion
Comments (5)
- Popular
- New
- Old
You must be signed in to leave a comment
Switch/Cypher
8 November 2020, 21:45
If you want that to compile:
But even then the two print outputs print the same thing. 0
Switch/Cypher
8 November 2020, 21:41
What is this program supposed to do?
You don't have a constructor for SolEscape so you can't pass "Dinesh" to it like that.
0
Dinesh
9 November 2020, 06:13
This was the Program from one of the task to print special character, going through the lesson I tried to modify and print the string along with name in 3 ways as it was explained but not getting the proper output
public class SolEscape {
public String name;
public SolEscape(String name){
this.name = name;
}
public static void main(String[] args) {
//System.out.println("This is Windows Path: \"C:\\Program Files\\Java\\jdk1.8.0_172\\bin\"");
//System.out.println("This is a Java String: \\\"C:\\\\Program Files\\\\Java\\\\jdk1.8.0_172\\\\bin\\\"");
SolEscape solescape = new SolEscape("Dinesh");
System.out.println("This is Escape Sequence Example " + solescape);
System.out.println("This is Escape Sequence Example " + solescape.toString());
/*SolEscape solescape = new SolEscape("Dinesh");
String escape = solescape.toString();
System.out.println("This is escape Sequence Example " + escape);*/
}
}
0
Switch/Cypher
9 November 2020, 10:44
Ok, two things:
Firstly make sure you are using IntelliJ - that will really help you because it will flag up a bunch of these problems for you and suggest where you might be going wrong.
Secondly - when you post code use the code button - its at the top of the window you type into on the right. It will put two html tags into the chat window and you copy and paste your code between the tags. This will help us all to see your code properly.
As I remember you just need to 'escape' the special characters by using extra '/' . I suspect you don't need any of the 'class' and constructor elements in your code. At the moment you are printing out two class elements "toString" which will only print the 'reference' to that class in the memory, which I guess isn't what you want.
0
Dinesh
10 November 2020, 13:30
Thanks for your kind suggestions regarding code representation. I will follow the same from now.
Yes, you are right its just printing the reference rather than the name.
Why so? What to do print the value
0