Changes
Jump to navigation
Jump to search
← Older edit
Newer edit →
Java
(view source)
Revision as of 10:22, 20 April 2022
678 bytes added
,
10:22, 20 April 2022
m
→Map
Line 3:
Line 3:
===With apt===
===With apt===
<nowiki>sudo apt-add-repository ppa:webupd8team/java
<nowiki>sudo apt-add-repository ppa:webupd8team/java
−
sudo apt-get update
+
sudo apt-get update
−
sudo apt-get install oracle-java8-installer</nowiki>
+
sudo apt-get install oracle-java8-installer</nowiki>
Also ensure your JAVA_HOME variable has been set to:
Also ensure your JAVA_HOME variable has been set to:
Line 431:
Line 431:
</syntaxhighlight>
</syntaxhighlight>
−
=== Map ===
+
===Map===
Key - Value Pair
Key - Value Pair
Line 506:
Line 506:
}
}
}
}
−
</source>
+
</source
><syntaxhighlight lang="java">
+
import java.util.HashMap;
+
import java.util.Map;
+
+
+
public class MapRunner {
+
public static void main(String[] args){
+
String str = "Text to count words and letters";
+
+
Map<Character, Integer> occurances = new HashMap<>();
+
char[] chars = str.toCharArray();
+
for (char character:characters){
+
Integer integer = occurances.get(character);
+
if (integer == null) {
+
occurances.put(character, 1);
+
} else {
+
occurrances.put(character, integer + 1);
+
}
+
System.out.println(occurrances);
+
}
+
+
+
}
+
}
+
</syntaxhighlight><br /
>
==Setters and 'this'==
==Setters and 'this'==
<source lang="java">
<source lang="java">
Rafahsolis
Bureaucrats
,
Administrators
2,306
edits
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Page
Discussion
Variants
Views
Read
View source
View history
More
Search
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Tools
Special pages
Printable version