Dart StringBuffer hashCode
Syntax & Examples


StringBuffer.hashCode property

The `hashCode` property in Dart returns the hash code for the object.


Syntax of StringBuffer.hashCode

The syntax of StringBuffer.hashCode property is:

 int hashCode 

This hashCode property of StringBuffer the hash code for this object.

Return Type

StringBuffer.hashCode returns value of type int.



✐ Examples

1 Getting the hash code of a non-empty StringBuffer

In this example,

  1. We create a `StringBuffer` named `buffer` with the content 'Example'.
  2. We print the value of the `hashCode` property, which returns the hash code of the buffer object.

Dart Program

void main() {
  StringBuffer buffer = StringBuffer('Example');
  print(buffer.hashCode);
}

Output

1037055266

2 Getting the hash code of an empty StringBuffer

In this example,

  1. We create an empty `StringBuffer` named `emptyBuffer`.
  2. We print the value of the `hashCode` property, which returns the hash code of the buffer object.

Dart Program

void main() {
  StringBuffer emptyBuffer = StringBuffer();
  print(emptyBuffer.hashCode);
}

Output

713284668

Summary

In this Dart tutorial, we learned about hashCode property of StringBuffer: the syntax and few working examples with output and detailed explanation for each example.