A c# dev starting a Java course
Tags: java, oo
Published: 2018-09-21 19:58:39

---
title: A c# dev starting a Java course
published: true
description: A c# dev's first experiences with Java
tags: java, oo
---

I have started a module with the Open University where I am to learn OO concepts through learning and using Java. As personal documentation as well as interest for anyone I decided that I would document my journey. 

Before we begin, my background for the last 4 years or so has been specifically using c# in my profession, first as an automated tester then as a software engineer so I am familiar with the OO principles and concepts. Though I will admit my theory lacks because I did not go to university or study any CS course previous to the one I'm on now. I have used other languages but Java is not one that I have really touched but being so similar to c# I have heard it talked about many times so I was clued up on at least some of the differences I would face when learning it. 

Below are my first discoveries as I embarked on the course.

### I want my IDE
The tool of use by the University is BlueJ. And although I can see the appeal for those that are learning OO and Java I'm having a real battle coming from Visual Studio and VS Code. Where is my Intellisense! It feels like a step backwards and an experience that is not relative to the real world. 

### Collections are a lot harder! 
Ok I admit maybe Linq has spoiled me but working with collections seems unnecessarily hard. It seems like there is a lot of code required to just create a new List and iterate through this. Maybe this is just me and I hope that in a few weeks I'll be laughing at this and ranting in the comments about how easy it in fact is.

### Where is my entry point 
I ran into this when I wanted to create a hello world console app. After a quick search it turns out that it’s just the method 
```
public static void main() { 
...
} 
```
and this can be in any class. I guess this can be both a pro and a con.

### Always Type
I'm a big user of _var_ in c# and pretty much any keyword that is general and gets the compiler to work out the type. But in Java you must set the Type everytime. Not a big thing and can in some cases be beneficial making sure the variable is definitely the type you expect

```
String name  = "John Doe";
```

### Capital String and Boolean, lowercase int?
From what I seem to be able to gather the types have different casing to each other. In c# it's pretty much all lower case
c#
```
string Name;
int Age; 
boolean IsVerified;
```

but in Java they are 

```
String name;
int age; 
Boolean isVerified
```

### More casing issues
This one I'm used to as I've worked with JS and TS and also just aware of it anyway but method names and instance variable (in c# known as properties) start with lowercase 

```

private String name;

public void setName(String name){
 this.name = name;
}
...

```

### Explicit Getters and Setters
I was shocked to be told to have to create and expose getters and setters methods for each instance variable I wanted to expose and manipulate. I much prefer c#'s way of handling this

c#
```
public string Name { get; set; } 
```

Java 
```
private String name;

public String getName(){
   return name;
}

public void setName(String name){
   this.name = name
}
```

## To Sum up
It may seem like I'm complaining about Java and perhaps I come across as a c# fanboy but really what do you expect, that's my world and has been for a few years now so it's going to take some adjustment. 
I hope to keep documenting my learnings as I delve deeper into the world of Java, after all there is a reason it's still so popular!