Download presentation
Presentation is loading. Please wait.
1
CS230 Tutorial Week 4
2
Agenda More Java (Very Briefly!) Useful Eclipse Tips! More questions.
3
final Lang-ref Section 4.12.4, 8.1.1.2, 8.3.1.2, 8.4.3.3
Generally means ‘constant’ A final variable/field can be assigned only once. A final class cannot be subclassed. A final method cannot be overridden. COMPILE-time error if violated. Very useful in nested classes and lambda-expressions.
4
Generics No such thing in Python --- duck typing.
No such thing in C --- weakly typed. Very powerful feature (but optional) in C template metaprogramming. Mandatory to program functionally --- Haskell and ML. Java generics sits between C and C easier to use/less powerful than C++, but still very useful. Added after Java 5.0 (in 2004!) --- has to be backwards compatible --- type erasure and JVM.
5
Generics Lang-ref Section 4.4 --- 4.10 (Especially 4.5)
Basic syntax is very easy! List<String> list = new ArrayList<String>(); list.add("hello, world!"); Detailed semantics is very tricky! --- Probably not useful to know to program Java at this level.
6
Nested Classes Rather unpleasant feature of Java --- very wired semantics. Lang-ref Section 8.1.3 static vs non-static nested classes. Most time you want a nested class, it’s a static nested class.
7
Eclipse Features More than just syntax --- Eclipse understands semantics. Eclipse understands your code (and Java), and can give you suggestions. Eclipse also has a very useful set of refactoring tools that can perform many of the standard refactoring techniques (in book Refactoring: Improving the Design of Existing Code by Martin Fowler) automatically.
8
Demos Auto-generate boilerplate code/comment.
Correct Indentation/Format Auto-complete. Code suggestions. Rename/Move. Show references. More advanced refactoring techniques --- extract methods/interfaces/super classes, pull up/down, etc.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.