• No results found

Lektion 8 - klassen String

N/A
N/A
Protected

Academic year: 2021

Share "Lektion 8 - klassen String"

Copied!
5
0
0

Loading.... (view fulltext now)

Full text

(1)

Lektion 8

(2)

Klassen String

Definiera och tilldela ett String-objekt:

String s = ”Mathias Magnusson”; Ta reda på antalet tecken i strängen s:

int längd = s.length(); Ta reda på tecken på en viss position: char tecken = s.charAt(3);

Mathias Magnusson s 17 längd h tecken

(3)

Klassen String

String n1 = ”Mathias”; String n2 = ”Peter”; Jämför n1 och n2: n1.equals(n2) n1.equalsIgnoreCase(n2)

Ger true om de är lika, false annars.

Mathias n1

Peter n2

(4)

Klassen String

String n1 = ”Mathias”; String n2 = ”Peter”; Jämför i bokstavsordning: n1.compareTo(n2) n2.compareToIgnoreCase(n2) Returnerar 0 om n1 och n2 är lika,

ett negativt tal om n1 kommer före n2 i alfabetet, ett positivt tal om n1 kommer efter n2 i alfabetet. Det finns fler metoder till klassen String:

http://docs.oracle.com/javase/7/docs/api/java/lang/String.html

Mathias n1

Peter n2

(5)

Uppgifter för veckan

Veckans uppgifter finns på utdelat material och utlagd på googlesiten:

https://sites.google.com/site/javaprogrammeringmednv/lektion er/lektion-12---metoder

References

Related documents

Skriv ett program som läser in dagens datum på formen 19åå-mm-dd , dvs en textsträng.. Sen läser du in en persons födelsedag på formen ååmmdd och skriver

ida_itemname

The Quartet has collaborated with some of this generation’s most important composers, including Gunther Schuller, John Cage, Gyorgy Ligeti, Steve Reich, Osvaldo Golijov,

Borromeo’s visionary performances include both fresh interpretations of the classical music canon and works by 20 th and 21 st century composers.. MAY 5,

The Quartet has collaborated with some of this generation’s most important composers, includ- ing Gunther Schuller, John Cage, Gyorgy Ligeti, Steve Reich, Osvaldo Golijov,

Highlights of their 2014-15 season include concerts at Carnegie Hall, the Philadelphia Chamber Music Society, and the Terra di Siena Chamber Music Festival in Tuscany; a

During a ricochet stroke the axis (i.e., the frog) is moved in a more or less straight (horizontal) line in the stroke direction as long as (the rotational) bouncing takes place.

String je v Pascalu reprezentován pomocí pole znaků, z čehož se dá očekávat, že zacházení s proměnnou typu String bude velice podobné zacházení s