LagosJUG Meeting With Heather Vancura Of The Java Community Process

LagosJUG Sponsors

I thought I’d write about the LagosJUG event, you know make sure the goals and purpose of the event is driven home properly. The event featured 4 speakers delivering critical discussions on tech and open source collaboration.

Keynote speaker was Heather Vancura, Chair of Java Community Process. She gave a detailed overview of the evolution of the Java programming language, whats new in Java 9 and how Oracle has tried hard in making sure the system was open and fair. She also encouraged individuals to identify with their local user groups who in-turn would ensure individuals participate in the collaboration and contribution to the java programming language. Emphasis were also placed on the adopt a JSR initiative. Here is a link to her slide.

Stephen Ugbogu, Head of LagosJUG picked quite a interesting topic to dwell on “Core software design principles”. I’ve got a question for you. How many lines of code should a method have on a standard screen?. I know what you thinking, whats a standard screen? well according to the International Organization for Standardization (ISO) on screen resolu…scratch that! There’s no such thing as a standard screen when it comes to codes, but its all about the method! The moment a method performs more than one action. please start deleting away. want to learn more? download his slides here.
Participants got their hands dirty when Ezewuzie Emmanuel Okafor (someone please call him Wuzie for short!) came on board showing us how to create REST Services using JAX-RS on a glass fish server. Here’s a link to the source codes on github and slides
Lagos Java Users (LagosJUG)The last speaker’s talk was more like a pep talk if you ask me. I should know cause I gave it. I tried encouraging participants on the need to embrace open source projects. Though we are aware of how daunting taking your first steps could be, but lagosJUG is taking steps to ensure everyone, beginners and experts alike are all carried along and to be honest, everyone is learning!.
That said, I’d like to give a shout out to all our sponsors, we couldn’t have done it without you! Thank you Seamfix for the event space, Oracle, and our very own Codeniro. Y’all rock!

That pretty much sums it up 🙂 want to join/sponsor the Lagos Java Users community?, here’s our official twitter handle, do give us a shout out and we’ll be more than happy to connect with you.

#Sights

LAGOS JUG WELCOMES HEAD OF JCP HEATHER VANCURA

lagos jug logo designed by frank akogun
“Patrick Curran won’t be coming to Lagos anymore for the tour”, those were the words the Lagos JUG president said and boy did those smiles turn upside down. The Lagos JUG community had prepared for his coming with great expectations. It hurt the excos more than it did the members, we felt it would be a great chance to boost the morale of our members, let them know Oracle/Java depended on them in pushing the Java frontiers in Nigeria and Africa as a whole.

Months after and bam! We are pleased to inform the public that Lagos JUG will be hosting Heather Vancura the new head of jcp (Java Community Process) in Lagos Nigeria.

The event promises to be rewarding, with talks from experienced Java developers in the industry. namely, Stephen Ubogu on “Core software design principles” and Ezewuzie Emmanuel Okafor. Heather Vancura will also be addressing participants at the event.

The Lagos Java User Group has tried hard in encouraging the local community to participate in the development of the Java programming language, be it small or big, I have no doubt that this event will help foster that.

To apply, visit the link, please note that seats are limited and attendance is strictly by invitation.

Introduction to algorithms using java

[code lang=”java”]
public class Algo {

private int[] arrayList = new int[20];
private int arraySize = 10;

public void arrayGenerator(){
for (int i =0; i<arraySize; i++){
//generate random numbers between 10 and 19
arrayList[i]= (int) (Math.random()*10)+10;
}
}

public void printArray(){
System.out.println("———-");
for (int i=0; i<arraySize; i++){
System.out.print("| " + i +" | ");
System.out.println(arrayList[i] + " |");
System.out.println("———-");
}
}

public static void main(String[] args) {
Algo con = new Algo();
con.arrayGenerator();
con.printArray();

}
}
[/code]

Line 3 and 4 basically creates a new array, with an initial size of 20, we later go ahead and limit the fields to be populated to 10. that would do for this tutorial 🙂

Line 7 declares a method called arrayGenerator, arrayGenerator when called, fills the array with random numbers. and finally line 15 displays the contents of the array calling the method printArray

instantiating our class on line 26, we call the arrayGenerator method before printing the values of the array. below is a screenshot of what you should expect.

Introduction to algorithm using java

Getting an element by it’s index

[code lang=”java”]
public int getValueByIndex(int index){
if(index < arraySize){
return arrayList[index];
}
return 0;
}
[/code]

It’s important you ensure that the search index being passed to the method is within the array size. (remember we set a limit of 10!) passing a search index of 11 upwards would lead to a error. we only return the value at the given index if it is less than the agreed array size if(index < arraySize)… running algo.getValueByIndex(4) should give you 17. 17 is the value whose index is 4. refer to the screenshot above.

Confirm if a given value is present

[code lang=”java”]
public boolean confirmValue(int value){
boolean status = false;
for(int i=0; i<arraySize; i++){
if (arrayList[i] == value){
status = true;
}
}

return status;
}
[/code]

We create a method that returns True or False (denoted by public boolean methodName..). Notice I did not bother checking the size of the incoming argument, any given integer value is perfectly fine. We loop through the array 10 times. For each iteration, we compare the value of each element in our array (arrayList[i]) with that of the given value. this comparison is done in a if statement. unless both values match, the value of status remains false! Once a match is found, we set status equal to True.

run algo.confirmValue(17) //returns True

Delete a value by it’s index

[code lang=”java”]
public void deleteByIndex(int index){
if(index < arraySize){
for(int i = index; i<(arraySize-1); i++){
arrayList[i]= arrayList[i+1];
}

arraySize–;
}

}
[/code]

Following the same ol rules, you want to ensure the index being passed is within the agreed array size (arraySize is 10). Let’s imagine a user passes 4, i becomes 4, we are going to loop through the array for as long as 4 the index is less than 9. here we go

while i=4, i<(arrayList-1) returns true, because 4 is less than 9, then we go into the loop, arrayList[4] which has the value 17 is our target, that's what we want to delete. arrayList[i] = arrayList[i+1] is the same as arrayList[4] = arrayList[4+1], this is how we delete the particular index, we simply overwrite it, we take the 5th element and place its value into the 4th element, the next time we loop again we encounter i++, this increments i by 1, so i becomes 5. arrayList[i] = arrayList[i+1] becomes arrayList[5] = arrayList[5+1] so we take the value of the 6th element (arrayList[5+1]) and place it in the 5th element (arrayList[5]), this way we ensure that other elements get pushed up into the array. get it? and finally we run arrayList--. since we deleted an array, the size no longer becomes 10 but 9, so the new size is arrayList-- (which means 9)

Inserting a value into the array

[code lang=”java”]
public void addValue(int value){
if(arraySize < 20){
arrayList[arraySize]=value;
arraySize ++;
}
}
[/code]

This is quiet easy, when adding an element into the array, we check to see if the arraySize is less than 20, remember private int[] arrayList = new int[20];. the maximum number of elements our array can take is 20. once this condition is met, we proceed by passing the arraySize as the index. this way we are certain that the element appears as the last element in the array. and finally we increase the array size i.e arraySize ++;