Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
String Properties and Methods | List and String
course content

Course Content

Introduction to Dart

String Properties and MethodsString Properties and Methods

What is the Difference Between Method and Property ?

Methods are like operations or actions you can perform on an object. For example, think of a ball. When you kick the ball, that's an action - a method. You're doing something with the ball.

Properties are like characteristics of an object. For example, the color of the ball or its size. Properties describe the object but don't perform actions on it.

So, methods are actions, and properties are characteristics. In the case of String, methods, and properties can be used to work with text.

String properties

  • length - Returns the length of the string including space.
dart

main.dart

First, a variable word is created, and it's assigned the String 'Codefinity'.

Then, the length property is called on the word String. This property counts the number of characters (letters) in the String and returns that value.

The obtained value (the number of characters in the 'Codefinity' String, which is 10) is passed to the print() function for output.

As a result, the number 10 is displayed on the screen, indicating the number of characters in the 'Codefinity' String.

  • The isEmpty method is used to check if a string is empty, meaning it doesn't contain any characters:
dart

main.dart

So, the isEmpty method helps to check if a String is empty, returning true if the string is empty or false if the String contains at least one character. This is useful for determining whether certain actions should be taken based on whether a String is empty or not.

Strings Methods

  • toLowerCase(): This method converts all characters in a String to lowercase. It allows you to ensure a consistent lowercase representation of characters, which can be useful when comparing two strings regardless of their case or when you want the text to be consistently in lowercase:
dart

main.dart

  • toUpperCase(): This method converts all characters in a String to uppercase. It's used to create text where all letters are in uppercase, which can be helpful when you want to display text in a title-like format or make the text more prominent:
dart

main.dart

So, the toLowerCase() and toUpperCase() methods allow you to easily manipulate the case of characters in strings, making them valuable in various programming and text processing scenarios.

Task

question-icon

Convert all characters of the string "word" to uppercase.

print();

Click or drag`n`drop items and fill in the blanks

Everything was clear?

Section 4. Chapter 5
course content

Course Content

Introduction to Dart

String Properties and MethodsString Properties and Methods

What is the Difference Between Method and Property ?

Methods are like operations or actions you can perform on an object. For example, think of a ball. When you kick the ball, that's an action - a method. You're doing something with the ball.

Properties are like characteristics of an object. For example, the color of the ball or its size. Properties describe the object but don't perform actions on it.

So, methods are actions, and properties are characteristics. In the case of String, methods, and properties can be used to work with text.

String properties

  • length - Returns the length of the string including space.
dart

main.dart

First, a variable word is created, and it's assigned the String 'Codefinity'.

Then, the length property is called on the word String. This property counts the number of characters (letters) in the String and returns that value.

The obtained value (the number of characters in the 'Codefinity' String, which is 10) is passed to the print() function for output.

As a result, the number 10 is displayed on the screen, indicating the number of characters in the 'Codefinity' String.

  • The isEmpty method is used to check if a string is empty, meaning it doesn't contain any characters:
dart

main.dart

So, the isEmpty method helps to check if a String is empty, returning true if the string is empty or false if the String contains at least one character. This is useful for determining whether certain actions should be taken based on whether a String is empty or not.

Strings Methods

  • toLowerCase(): This method converts all characters in a String to lowercase. It allows you to ensure a consistent lowercase representation of characters, which can be useful when comparing two strings regardless of their case or when you want the text to be consistently in lowercase:
dart

main.dart

  • toUpperCase(): This method converts all characters in a String to uppercase. It's used to create text where all letters are in uppercase, which can be helpful when you want to display text in a title-like format or make the text more prominent:
dart

main.dart

So, the toLowerCase() and toUpperCase() methods allow you to easily manipulate the case of characters in strings, making them valuable in various programming and text processing scenarios.

Task

question-icon

Convert all characters of the string "word" to uppercase.

print();

Click or drag`n`drop items and fill in the blanks

Everything was clear?

Section 4. Chapter 5
some-alt