What do you want to save?
Add Code snippet
New code examples
-
Python 2021-09-25 03:10:05
python string assignment by index
# Strings are immutable in python, so you cannot insert characters. # You could do convert it to a list however: text = "Hello Warld" text = list(text) text[7] = "o" text = "".join(text) >>>text "Hello Wor... Add solution -
Other 2021-09-24 14:59:02
string constant pool
String uses a special memory location to reuse of String objects called String Constant Pool. String objects created without the use of new keyword are stored in the String Constant Pool part of the heap. It doesn't create the same string object if there ... Add solution -
Java 2021-09-18 14:08:02
Why String is popular HashMap key in Java?
Since String is immutable, its hashcode is cached at the time of creation and it doesn't need to be calculated again. This makes it a great candidate for key in a Map and its processing is fast than other HashMap key objects. This is why String is mostly ... Add solution -
Python 2021-09-17 17:14:02
AttributeError: This QueryDict instance is immutable django
#views.py from rest_framework import generics class Login(generics.CreateAPIView): serializer_class = MySerializerClass def create(self, request, *args, **kwargs): request.data._mutable = True request.data['username'] = "exa... Add solution -
Kotlin 2021-09-17 11:12:03
kotlin collection literals
listOf(1,2,3,4) // List<Int> mutableListOf(1,2,3,4) // MutableList<Int> setOf("A", "B", "C") // Set<String> mutableSetOf("A", "B", "C") // MutableSet<String> arrayOf('a', ... Add solution -
Swift 2021-09-16 00:21:04
swift apply changes after a word in string
let longString = "Lorem ipsum dolor. VeryLongWord ipsum foobar" let longestWord = "VeryLongWord" let longestWordRange = (longString as NSString).rangeOfString(longestWord) let attributedString = NSMutableAttributedString(string: long... Add solution