strings Archive

Strings in Python (Part II)

A segment of a string is called a slice. Selecting a slice is similar to selecting a character: >>> s = 'Monty Python' >>> print s[0:5] Monty >>> print s[6:13] Python If you omit the first index (before the colon), the slice starts at the beginning of the string. If you omit the second index, the

Strings in Python (Part I)

A string is a sequence of characters. The index indicates which character in the sequence you want to access and similar to Java indexing in python also starts from zero.You can access the characters one at a time with the bracket operator: >>> fruit = 'banana' >>> letter = fruit[1] >>> print letter a len

Strings in Java

Strings Representing a set of characters altogether, ¬†we can define the data type String is used. For example, Following line declares and initialize a String has an initial value “Welcome to Java” String str = "Welcome to Java"; String is predefined java class same like System, Scanner etc. String is not a primitive data type