amrut sabade wrote:Hii Ok. I have written something like this is it correct now how can i input 2 strings
You have written a method called "Main" (which happens to be the name as your class, which is not good). You should pick meaningful names for your methods. OK, to call the method you should create an instance of your class and call the method by passing the required parameters.
You could easily have tried this one. Yes, you can, but from main, not Main.
As Vijitha pointed out, you have a method with the same name as your class. You argued that this is a constructor, but it isn't. Have a closer look at it.
Life is full of choices. Sometimes you make the good ones, and sometimes you have to kill all the witnesses.
What everyone is trying to wanr you is that the entry point of a Java program is a class having a method called "public static void main(String args)". If you name your class Main, and make constructors in this class, this may be confusing :
As Jan said, constructors do not return values, so you cannot have public String Main(String a,String b).
Can you tell us exactly what the content of your assignment is ?I feel that some information is missing.
It's because you are hiding the default constructor with your Concat(String a,String b) constructor. But that's not the real problem. The real problem is that you have to pass strings to your constructor. Like you would with a method having parameters. Can you figure out how ?
Ok.. i understod it but i want to do it using constructor only.. thaths the prob i can write method and do it..
posted 8 years ago
Hey finally i have done with the assignment
Thanks a lot Guys Vijitha Kumara,Christophe Verré ,Jan Hoppmann ..... withou your help it woudent be possible... really thanks a lot and looking forward to your help in the way of learning
FINALLY MY PROG IS AS BELOW..
posted 8 years ago
Hey Guys can you tell me sompe sample programes that i should try to implement so that i should get my bascis clear...
can you help me ...