Java for TypeScript Developers
Transfer TypeScript experience to Java through explicit types, collections, methods, and object contracts. Build a connected multi-file order processor and port a stock ledger.
TypeScript and Java side by side
The same program in TypeScript and in Java, from the lessons of this course.
Strings and Output
TypeScript checks string expressions before runtime but retains JavaScript template literals and console behavior. Type annotations do not change interpolation or insert a Java entry class. Java string formatting is different even when both source programs…
TypeScript1export {};2const name: string="Ada";console.log(`Hi ${name}`,"!");Java1import java.util.*;2import java.util.function.*;3import java.util.stream.*;4public class Example {5 6public static void main(String[] args) {7String name="Ada";System.out.println("Hi "+name+"!");8}9}String Equality
TypeScript primitive string equality uses JavaScript strict-equality rules even when both operands carry string annotations. Java String references require content equality through equals. TypeScript structural assignability is a compile-time relation and…
TypeScript1export {};2const a:string=["a","b"].join(""),b:string="ab";console.log(a===b);Java1import java.util.*;2import java.util.function.*;3import java.util.stream.*;4public class Example {5 6public static void main(String[] args) {7String a=new String("ab"),b=new String("ab");System.out.println(a.equals(b));System.out.println(a==b);8}9}Fixed-size Arrays
TypeScript number[] checks element types but does not make the runtime array fixed-length. Tuple types can describe particular positions, yet their enforcement is still a compile-time facility. Java array length is fixed at runtime and index bounds are…
TypeScript1export {};2const a:number[]=[2,4,6];console.log(a.at(-1));Java1import java.util.*;2import java.util.function.*;3import java.util.stream.*;4public class Example {5 6public static void main(String[] args) {7int[]a={2,4,6};System.out.println(a[a.length-1]);8}9}While and Early Exit
TypeScript types do not change the runtime meanings of break and continue. Narrowing may help after checks inside a loop, but Java requires its condition to be boolean. A word sentinel and an empty item illustrate distinct decisions: end traversal versus skip…
TypeScript1export {};2const kept:string[]=[];for(const word of ["tea","","STOP","coffee"]){if(word==="STOP")break;if(word==="")continue;kept.push(word);}console.log(kept.join(","));Java1import java.util.*;2public class Example {3public static void main(String[] args) {4List<String> kept=new ArrayList<>();5for(String word:new String[]{"tea","","STOP","coffee"}) {6 if(word.equals("STOP")) break;7 if(word.isEmpty()) continue;8 kept.add(word);9}10System.out.println(String.join(",",kept));11}12}Static Methods and Returns
TypeScript functions can declare parameter and return types at module scope. Java requires methods to belong to classes. TypeScript structural function compatibility describes callable values, while Java callbacks are expressed through functional interfaces…
TypeScript1export {};2function hours(total:number):number{return Math.trunc(total/60);}console.log(hours(125));Java1import java.util.*;2import java.util.function.*;3import java.util.stream.*;4public class Example {5static int hours(int total){return total/60;}6public static void main(String[] args) {7System.out.println(hours(125));8}9}Input and Exact Formatting
TypeScript parseInt returns number and still accepts a numeric prefix before invalid trailing text. Its type does not prove that a value is integral, finite, or within Java int bounds. Java parsing checks a complete representation and may reject an otherwise…
TypeScript1export {};2const parsed:number=parseInt("12cats",10);console.log(parsed);Java1import java.util.*;2import java.util.function.*;3import java.util.stream.*;4public class Example {5 6public static void main(String[] args) {7int cents=305;System.out.println(String.format(Locale.ROOT,"tea: %d.%02d",cents/100,cents%100));8}9}
Syllabus
10 chapters48 lessons1 project48 challenges99 quiz questionsGetting Started in Java
6 lessonsValues and Decisions
5 lessonsCollections and References
5 lessonsIteration and Pipelines
5 lessonsMethods and Callbacks
5 lessonsInput, Errors, and Files
5 lessonsClasses and State
6 lessonsComposition and Contracts
5 lessonsProject: Order Processing
4 lessonsFinal Challenges
2 lessonsFrequently asked questions
Who is Java for TypeScript Developers for?
For people who already write TypeScript and want to learn Java. Each lesson starts from TypeScript you know and shows how Java does the same thing, so you skip the beginner basics.
Do I need to know Java already?
No. The course starts with your first Java program. You need TypeScript basics: variables, conditions, loops, functions and collections.
How many lessons does Java for TypeScript Developers have?
Java for TypeScript Developers contains 48 interactive lessons you can complete at your own pace.
What does Java for TypeScript Developers cover?
The course is organized into chapters covering: Getting Started in Java, Values and Decisions, Collections and References, Iteration and Pipelines, and more.
Is Java for TypeScript Developers free?
Yes. Every course on Coddy is free to start. You can complete lessons in your browser without any downloads or signup.