+ 6

Does it always use capital 'S' for string?

28th Jul 2018, 12:18 PM
Chaerul Chuluq
Chaerul Chuluq - avatar
11 ответов
+ 15
In Java, String is a class. That is its S needs to be in capital letter
28th Jul 2018, 1:46 PM
Muhd Khairul Amirin
Muhd Khairul Amirin - avatar
+ 11
In Java? Yes. Only primitive data types are written in all lower-case, like int and double. You can think of String as a class that handles char data types.
28th Jul 2018, 12:53 PM
Jukka Kuusto
Jukka Kuusto - avatar
+ 7
Just to add to Jukka's answer - by convention all Java classes begin with an uppercase letter, and String is indeed a class
28th Jul 2018, 1:16 PM
Dan Walker
Dan Walker - avatar
+ 5
thank you for your answer Jukka Kuusto
28th Jul 2018, 12:55 PM
Chaerul Chuluq
Chaerul Chuluq - avatar
+ 4
Right! And Classes are essentially non-primitive data types :)
28th Jul 2018, 1:20 PM
Jukka Kuusto
Jukka Kuusto - avatar
+ 4
Exactly. Fun fact: primitive data types have corresponding, pre-defined classes, like Integer and Double. You need them when assigning types to collections and maps. Example: Map<String, Integer> You couldn't assign a primitive data type, like this: Map<String, int> Java would throw an error if you tried.
28th Jul 2018, 1:56 PM
Jukka Kuusto
Jukka Kuusto - avatar
+ 2
Even the void keyword has an associated class :) with reflection you can actually created a Void instance, though this is quite useless
28th Jul 2018, 2:15 PM
Dan Walker
Dan Walker - avatar
+ 2
All java class begin with uppercase letter( large or capital letter), and String is a class, So uses capital S.
29th Jul 2018, 6:59 AM
Fazal Amin
Fazal Amin - avatar
+ 2
In java programming language String is class. So 'S' is required for string.
29th Jul 2018, 11:01 AM
Kirtikumar
Kirtikumar - avatar
+ 2
Depends on the language. For example in C# "string" and "String" mean the same thing.
29th Jul 2018, 8:53 PM
Rusty.Metal
0
No, it doesn't use capital 'S' in c++ programming language for string.
29th Jul 2018, 10:59 AM
Kirtikumar
Kirtikumar - avatar