How do I get the user ID for the currently logged-in user? I want to get current user object (user information) in Drupal 8.  

I know in Drupal 7 there was a global $user variable; I want to know how I can get current user object in Drupal 8.
$user = \Drupal::currentUser();


See the Drupal class. There are a lot of helper methods; most of them are shortcuts for services, so you don't have to call \Drupal::service() directly.

Note that the current user is not the user entity, it is just user proxy. You can get some basic information from it but fields or other entity-specific logic is not present. To access the user entity you have to load it manually:

$user = User::load(\Drupal::currentUser()-&gt;id());


Unfortunately there is no direct method like \Drupal::currentUser()-&gt;getEntity() :(