Afrikaans
Akan
Albanian
Amharic
Arabic
Armenian
Azerbaijani
Basque
Belarusian
Bemba
Bengali
Bihari
Bosnian
Breton
Bulgarian
Cambodian
Catalan
Cebuano
Cherokee
Chichewa
Chinese (Simplified)
Chinese (Traditional)
Corsican
Croatian
Czech
Danish
Dutch
English
Esperanto
Estonian
Ewe
Faroese
Filipino
Finnish
French
Frisian
Ga
Galician
Georgian
German
Greek
Guarani
Gujarati
Haitian Creole
Hausa
Hawaiian
Hebrew
Hindi
Hmong
Icelandic
Igbo
Indonesian
Interlingua
Irish
Italian
Japanese
Javanese
Kannada
Kazakh
Kinyarwanda
Kirundi
Kongo
Korean
Krio (Sierra Leone)
Kurdish
Kurdish (Soranî)
Kyrgyz
Laothian
Latin
Latvian
Lingala
Lithuanian
Lozi
Luganda
Luo
Luxembourgish
Macedonian
Malagasy
Malay
Malayalam
Maltese
Maori
Marathi
Mauritian Creole
Moldavian
Mongolian
Myanmar (Burmese)
Montenegrin
Nepali
Nigerian Pidgin
Northern Sotho
Norwegian
Norwegian (Nynorsk)
Occitan
Oriya
Oromo
Pashto
Persian
Polish
Portuguese (Brazil)
Portuguese (Portugal)
Punjabi
Quechua
Romanian
Romansh
Runyakitara
Russian
Samoan
Scots Gaelic
Serbian
Serbo-Croatian
Sesotho
Setswana
Seychellois Creole
Shona
Sindhi
Sinhalese
Slovak
Slovenian
Somali
Spanish
Spanish (Latin American)
Sundanese
Swahili
Swedish
Tajik
Tamil
Tatar
Telugu
Thai
Tigrinya
Tonga
Tshiluba
Tumbuka
Turkish
Turkmen
Twi
Uighur
Ukrainian
Urdu
Uzbek
Vietnamese
Welsh
Wolof
Xhosa
Yiddish
Yoruba
Zulu
Two string is a method that returns every field as one string.
It's also a special method and you'll see why a very soon.
In this lesson, you're going to add it to string method to the car class.
To string, it connects every field of an object into a string.
Two string is a method that returns a string, and you can break it up into three parts.
It is public.
It has the name to string and it returns a string value.
In the car class, the phone, a two string method, public string.
To string.
The method returns a string.
And the string value needs to connect every field into a sentence.
So will return make.
And we'll connect the field, make.
And without a new line.
Then I'll say price.
And connect the price of the current object.
Then we'll connect the year field of the current object.
And we'll do the same for color.
In our last field as pirates, we're going to print the contents of this stop pirates using two string.
So when an object calls to string, it's going to connect every field from the object that calls it
into a string and return it.
Now, why is to string special when you print an object, J�vor looks for the two string method.
Try printing each object now and see what happens.
And check it out.
We printed every field in each object.
I hope your mind is blown because mine sure was when I found out about this.
But when you add a two string to your class, Java internally calls it, when you're printing the object
and the method returns a string that effectively describes the current object.
In practice, every class that models an object should have a two string method.
In this lesson, you add in a two string method to the car class.
When you had to string to your class, Jabor automatically calls it, when you're printing an object
of that class, ultimately to string makes it easy to print every field from the object that calls it
the current object.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.