0

I want to make an expression that would if put into code print the first char of first then a period followed by the first char of second and so on till third.

first.substring(0, 1) + "." + second.substring(0, 1) + "." + third.substring(0, 1)
7
  • 3
    What is the output that you are getting currently? Sample outputs will help as well. Commented Feb 6, 2013 at 0:32
  • 1
    For one, there's no semi-colon at the end. Commented Feb 6, 2013 at 0:33
  • I'm doing an online exercise that wants fragment code, all that it's telling me is that this is the wrong way to accomplish the task... Commented Feb 6, 2013 at 0:34
  • 1
    @SalRosa what is the actual task ? Commented Feb 6, 2013 at 0:34
  • 1
    It probably wants you to use charAt instead? Commented Feb 6, 2013 at 0:35

2 Answers 2

1

You could try using the charAt method.

first.charAt(0) should return the first character in first.

Or first, second, and third might not be defined in the context, be sure that you are using the same variable names and casing for them as the website expects.

Sign up to request clarification or add additional context in comments.

1 Comment

I got it to work turns out i need three ".", Thank you though.
1

using string concatenation print the first char of first followed by a period, then the first char of second followed by a period, then the first char of third followed by a period. So if first=guy, second=person, third=thing it would print g.p.t

first.charAt(0)+"."+second.charAt(0)+"."+third.charAt(0);

1 Comment

Shouldn't that be charAt(0)??

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.