#Index Question Java

1 messages · Page 1 of 1 (latest)

sick zealot
#

does the t in \t and the n in \n count towards the index count??

final jasper
#

The first \ doesn't count

#

It's an escape character

#

\t is one char \\ is also one char (which is the slash char)

sick zealot
#

i never knew the special character after the escape counted towards the index wth

coral stag
#

because
'\t' == tab
'\n' == new line
'\' is a backslash

#

;compile java

import java.util.*;
public class M
{
 public static void main(String a[])
 {
  String a0 = "\tCS\n312:312";
  System.out.println( Arrays.asList(a0.split("")) );
  System.out.println(a0.indexOf('\\') );
  System.out.println(a0.charAt(7) );

  String a1 = "\tCS\n312\\312";
  System.out.println( Arrays.asList(a1.split("")) );
  System.out.println(a1.indexOf('\\') );
  System.out.println(a1.charAt(7) );
 }
}