Difference between revisions of "Java/C2/Strings/English"
(Created page with ''''Title of script''': Strings in Java '''Author''': TalentSprint '''Keywords: '''datatype, char, strings, adding strings, video tutorial {| style="border-spacing:0;" | styl…') |
|||
(2 intermediate revisions by 2 users not shown) | |||
Line 31: | Line 31: | ||
| style="border:0.035cm solid #000000;padding:0.097cm;"| For this tutorial we are using | | style="border:0.035cm solid #000000;padding:0.097cm;"| For this tutorial we are using | ||
− | '''Ubuntu 11.10''', | + | '''Ubuntu 11.10''', JDK 1.6''' and |
− | '''Eclipse 3.7 | + | '''Eclipse 3.7' |
|- | |- | ||
Line 39: | Line 39: | ||
'''Prerequisites''' | '''Prerequisites''' | ||
− | | style="border:0.035cm solid #000000;padding:0.097cm;"| | + | | style="border:0.035cm solid #000000;padding:0.097cm;"| To follow this tutorial you must have knowledge of '''data types in Java.''' |
Line 68: | Line 68: | ||
'''}''' | '''}''' | ||
− | | style="border:0.035cm solid #000000;padding:0.097cm;"| we have the skeleton required for the rest of the code. | + | | style="border:0.035cm solid #000000;padding:0.097cm;"| we have the eclipse IDE and the skeleton required for the rest of the code. |
− | We have created a class | + | We have created a class '''StringDemo '''and added the main method. |
|- | |- | ||
Line 77: | Line 77: | ||
'''char star = '*';''' | '''char star = '*';''' | ||
− | | style="border:0.035cm solid #000000;padding:0.097cm;"| Inside the '''main''' method, type '''''char star '''equal to in single''' '''quotes''' star''''' | + | | style="border:0.035cm solid #000000;padding:0.097cm;"| Inside the '''main''' method, type '''''char star '''equal to in single''' '''quotes''' asrteicks star''''' |
Line 97: | Line 97: | ||
'''char c3 = 'r';''' | '''char c3 = 'r';''' | ||
− | | style="border:0.035cm solid #000000;padding:0.097cm;"| | + | | style="border:0.035cm solid #000000;padding:0.097cm;"| Remove the char line and type , |
'''char c1 '''''equal to''''' c''' | '''char c1 '''''equal to''''' c''' | ||
Line 125: | Line 125: | ||
Point to output | Point to output | ||
− | | style="border:0.035cm solid #000000;padding:0.097cm;"| | + | | style="border:0.035cm solid #000000;padding:0.097cm;"| type, |
Line 138: | Line 138: | ||
− | save | + | save the file and run it. |
Line 153: | Line 153: | ||
|- | |- | ||
− | | style="border:0.035cm solid #000000;padding:0.097cm;"| Remove everything inside the '''main''' function and type | + | | style="border:0.035cm solid #000000;padding:0.097cm;"| Remove everything inside the '''main''' function and type |
Line 166: | Line 166: | ||
− | We have use double quotes | + | We have use double quotes instead of single quotes as delimiters |
− | + | ||
This statement creates a variable '''greet''' that is of the type '''String''' | This statement creates a variable '''greet''' that is of the type '''String''' | ||
− | Let us print the message. | + | Now Let us print the message. |
|- | |- | ||
Line 178: | Line 177: | ||
'''System.out.println(greet);''' | '''System.out.println(greet);''' | ||
− | + | ||
− | Save | + | Save the file run it . |
Point to output | Point to output | ||
− | | style="border:0.035cm solid #000000;padding:0.097cm;"| | + | | style="border:0.035cm solid #000000;padding:0.097cm;"| |
− | + | ||
'''System.out.println(greet);''' | '''System.out.println(greet);''' | ||
− | Save | + | Save the file and run it |
− | + | As we can see, the message has been stored in the variable and it has been printed. | |
− | As we can see, the message has been stored in the variable and printed. | + | |
Line 218: | Line 215: | ||
Point to output | Point to output | ||
− | | style="border:0.035cm solid #000000;padding:0.097cm;"| | + | | style="border:0.035cm solid #000000;padding:0.097cm;"| |
− | + | ||
'''String name '''''equal to '''''“Java”;''' | '''String name '''''equal to '''''“Java”;''' | ||
Line 229: | Line 225: | ||
− | change '''println(greet)''' to '''println(msg)''' | + | change '''println(greet)''' to '''println(msg)''' save the file and run it. |
− | + | ||
− | + | ||
− | + | ||
Line 251: | Line 244: | ||
Point to output | Point to output | ||
− | | style="border:0.035cm solid #000000;padding:0.097cm;"| Let us create a space character<nowiki>;</nowiki> | + | | style="border:0.035cm solid #000000;padding:0.097cm;"|so Let us create a space character<nowiki>;</nowiki> |
− | '''char SPACE '''''equal to '''''' ';''' | + | '''char SPACE '''''equal to '''''' ';''' |
Line 263: | Line 256: | ||
− | Now add the space to the message. | + | Now let us add the space to the message. |
Line 269: | Line 262: | ||
− | + | save the file and run it | |
− | + | ||
− | Now the output is clear and as expected. | + | Now we can see the output is clear and as expected. |
Line 293: | Line 285: | ||
− | and a | + | and a word “java” to uppercase. |
Line 299: | Line 291: | ||
− | Let us run the file to see the output. | + | So Let us run the file to see the output. |
− | + | As we can see t he output is not clean. | |
Line 320: | Line 312: | ||
Point to output | Point to output | ||
− | | style="border:0.035cm solid #000000;padding:0.097cm;"| | + | | style="border:0.035cm solid #000000;padding:0.097cm;"| type, |
'''greet '''''equal to '''''greet.toLowerCase();''' | '''greet '''''equal to '''''greet.toLowerCase();''' | ||
Line 328: | Line 320: | ||
− | + | '''name '''''equal to '''''name.toUpperCase();''' | |
Line 334: | Line 326: | ||
− | + | Save the file and Run it. | |
Line 355: | Line 347: | ||
'''Summary''' | '''Summary''' | ||
− | | style="border:0.035cm solid #000000;padding:0.097cm;"| | + | | style="border:0.035cm solid #000000;padding:0.097cm;"| This brings us to the end of this tutorial. |
In this tutorial we have learnt | In this tutorial we have learnt | ||
− | '''- how to create strings and | + | '''- how to create strings and addstrings ''' |
'''- few string operations like converting to lower case and upper case''' | '''- few string operations like converting to lower case and upper case''' | ||
Line 368: | Line 360: | ||
− | | style="border:0.035cm solid #000000;padding:0.097cm;"| | + | | style="border:0.035cm solid #000000;padding:0.097cm;"| As a assignment, |
- Read about the '''concat''' method of Strings in Java. - Find out how is it different from adding strings. | - Read about the '''concat''' method of Strings in Java. - Find out how is it different from adding strings. |
Latest revision as of 12:35, 25 November 2014
Title of script: Strings in Java
Author: TalentSprint
Keywords: datatype, char, strings, adding strings, video tutorial
Visual Cue | Description |
Slide 1
Welcome |
Welcome to the spoken tutorial on Strings in Java. |
Slide 2
Learning Outcomes |
In this tutorial, you will learn how to
create strings, add strings and perform basic string operations like converting to lower case and upper case. |
Slide 3
Tools Used |
For this tutorial we are using
Ubuntu 11.10, JDK 1.6 and Eclipse 3.7' |
Slide 4
Prerequisites |
To follow this tutorial you must have knowledge of data types in Java.
|
Slide 5
Strings |
String in Java, is a sequence of characters.
|
Minimize Slides and open Eclipse
Eclipse should contain the following code public class StringDemo{ public static void main(String[] args){ } } |
we have the eclipse IDE and the skeleton required for the rest of the code.
|
Inside the main method, type
char star = '*'; |
Inside the main method, type char star equal to in single quotes asrteicks star
|
Type after the char...
char c2 = 'a'; char c3 = 'r'; |
Remove the char line and type ,
char c1 equal to c char c2 equal to a char c3 equal to r We have created three characters to make the word car.
|
Type after char3...
System.out.print(c2); System.out.print(c3);
|
type,
System.out.print(c2); System.out.print(c3);
|
Remove everything inside the main function and type
|
remove everything inside the main method and type
This statement creates a variable greet that is of the type String
|
Type the following
System.out.println(greet); Save the file run it .
|
System.out.println(greet); Save the file and run it As we can see, the message has been stored in the variable and it has been printed.
|
Change “Hello Learner” to “Hello“ | I'm removing the Learner from the message.
We'll store the name in a different variable. |
Type after the greet... line
String name = “Java”; String msg = greet + name;
|
String name equal to “Java”;
But there is no space separating them. |
Before String greet line, type this
char SPACE = ' ';
Point to output |
so Let us create a space character;
char SPACE equal to ' ';
save the file and run it Now we can see the output is clear and as expected.
|
Change “hello” to “HeLLo”
Change “Java” to “jAvA”
|
I’m changing a few characters of “Hello” to upper case
|
Add the following code before System...
name = name.toUpperCase();
|
type,
greet equal to greet.toLowerCase();
name equal to name.toUpperCase();
Save the file and Run it.
|
This is how we create strings and perform string operations.
We'll discuss them as we move on to complex topics. | |
Minimize the Eclipse window and switch to slides.
Summary |
This brings us to the end of this tutorial.
In this tutorial we have learnt - how to create strings and addstrings - few string operations like converting to lower case and upper case |
Slide 7Assignment
|
As a assignment,
- Read about the concat method of Strings in Java. - Find out how is it different from adding strings. |
Slide 8About the Spoken Tutorial Project
|
To know more about the Spoken Tutorial project, watch the video available at the following link.
If you do not have good bandwidth, you can download and watch it |
Slide 9Spoken Tutorial WorkshopsThe Spoken Tutorial Project Team
|
The Spoken Tutorial Project Team.
Conducts workshops using spoken tutorials. Gives certificates for those who pass an online test. For more details, please write to contact AT spoken HYPHEN tutorial DOT org. |
Slide 10Acknowledgement
|
Spoken Tutorial Project is a part of the Talk to a Teacher project and is supported by the National Mission on Education through ICT, MHRD, Government of India. More information on this Mission is available at spoken HYPHEN tutorial DOT org SLASH NMEICT HYPHEN Intro |
Slide 11About the contributor
|
This tutorial has been contributed by TalentSprint. Thanks for joining.
|