Friday 25 July 2014

FRSC WILL FROM AUGUST 1 ARREST DRIVERS WITHOUT NEW LICENCE

FRSC will from August 1 arrest drivers without new licence

The Federal Road Safety Commission (FRSC) will go full blast in the enforcement of the new drivers' licence and number plate from Aug. 1, the Lagos State Sector Commander of FRSC, Mr Chidi Nkwonta, has said.


Nkwonta told newsmen that the decision followed the new court judgment, which empowers the commission to enforce the policies.

He said Tuesday in Lagos, 'This new judgment made it very clear that as from Aug. 1, FRSC should impound. So, Nigerians must discountenance that first misleading judgment and take this one because we are going to continue enforcement as from Aug. 1, 2014. We never asked anybody to stop processing licences. Anybody who stopped ab initio, stopped at his own peril.  Neither did the court ask anybody to stop; that judgment never said anybody should stop. So anybody who did so did it at his own risk and the deadline was supposed to be June 30. Now, we have extended it to Aug. 1, because we needed to go on appeal on the other matter.

'But right now, there is another judgment which says we can go on. So, while we are still waiting for the appeal, we are going to go on with this other judgment,' he said.

Justice Peter Umeadi of a Federal High Court in Anambra State on June 30, had ruled in a suit filed by Chief Ajefo Ekwo, challenging FRSC's powers to enforce new drivers' licence and number plates.

Umeadi said the respondent's directive to change old drivers' licence and number plates to new was legal, valid, subsisting and in conformity with the FRSC's 2007 Act and the National Road Traffic Regulations of 2012.

Nkwonta maintained that the recent judgment set aside the earlier judgment of the Lagos High Court, which said that the corps had no authority to produce and fix deadline for the documents.

According to the FRSC commander,the earlier judgment was given in error and that the commission would stand by the new judgment, while appealing against the earlier one.

He said all registration centres and 18 additional work stations in all parts of Lagos were functional and that the network was effective.

Nkwonta said the commission had improved the process, just as it is working at weekends to make it easy for applicants.

Justice John Tsoho of the Federal High Court in Lagos on March 26, declared that the FRSC had no legal authority to impose new number plates on motorists in the country.

The judge also held that 'the ongoing exercise by the FRSC to replace the old number plate with a new one is illegal and unconstitutional because there is no law empowering it to carry out the exercise.''

NFF BOARD IMPEACHES AMINU MAIGARI, MANDATES CONTRACT RENEWAL FOR KESHI

NFF board impeaches Aminu Maigari, mandates contract renewal for Keshi

The Nigeria Football Federation board, on Thursday in Abuja impeached its chairman Alhaji Aminu Maigari.

The Board asked Maigari's Vice, Chief Mike Umeh, to take over the leadership of the Glass House.

The Executive Committee of NFF also mandated its technical subcommittee to open discussion with the Chief Coach of the Super Eagles, Stephen Keshi on a possible renewal of his contract which expired after the FIFA World Cup in Brazil.

The decision on Keshi was taken after the committee impeached erstwhile president, Alhaji Aminu Maigari during a meeting in Abuja on Thursday.

A communiqué of the meeting signed by Chief Emeka Inyama says 'the Executive Committee has mandated the technical subcommittee to open channels of communication with Keshi with a view to extending his contract, as the NFF is still interested in working with him. The sub-committee is to report back to the Executive Committee within a week.

'The Committee mandated the NFF management to proceed with discussions with a number of African countries with the view to seeing the Super Eagles playing a friendly match on FIFA window of Wednesday, 13 August, as part of preparations for the 2015 African Cup of Nations qualifying matches.

'The committee expressed satisfaction with all arrangements so far made for the different national teams, namely; Falconets, Flying Eagles and Golden Eaglets ahead of important international matches and qualifying games, and also directed the technical subcommittee to meet in a few days to harmonise all arrangements in this regard.'

It was also agreed at the meeting that 2014 Men and Women Federation Cup competitions will hold as scheduled in Lagos on Saturday, 16 August, while the planned Elective Congress/General Assembly of the NFF will still hold as scheduled on Tuesday, 26 August.

Meanwhile, an Emergency Congress of the NFF will be convened in the Federal Capital Territory, FCT, Abuja on Thursday, 31 July, to ratify the impeachment of Maigari from the NFF Executive Committee.

'Henceforth, all financial issues with players and officials must be thoroughly deliberated upon and agreed ahead of major matches and competitions, to avoid the kind of embarrassment brought upon the nation at the 2014 FIFA World Cup finals in Brazil, when players boycotted training sessions before the Round of 16 match against France,' the communiqué read.

At the meeting after Maigari's impeachment, were Chief Mike Umeh (Acting President); Emeka Inyama (member); Mrs. Dilichukwu Onyedinma (member); Chief Effiong Johnson (member); Barr. Christopher Green (Member); Shehu Adamu (member); Alhaji Muazu Suleyman (member); Mr. Ayodeji Tinubu (Member); Alhaji Yusuf Ahmed 'Fresh' (member); Chief Felix Anyansi Agwu (member); Suleiman Yahaya-Kwande (member) and Secretary general Musa Ahmadu.


IG moves to unravel motive behind bomb attack on Buhari, sets up probe team



IG moves to unravel motive behind bomb attack on Buhari, sets up probe team
The Inspector-General of Police, IGP Mohammed D. Abubakar on Friday announced the institution of a high-power investigation team to unravel the perpetrators of the Wednesday bomb attack on the former Head of State and chieftain of All Progressives Congress (APC), Muhammadu Buhari, and an Islamic cleric Sheikh Dahiru Bauchi.

Both Buhari and Bauchi narrowly escaped death during the attacks in Kaduna in which thirty-nine (39) Nigerians unfortunately lost their lives while thirty-seven (37) others got injured.

Police boss in a statement by Force Public Relations Office, ACP Frank Mba, said the team of investigators, which is expected to work in close collaboration with other security agencies, is headed by the Commissioner of Police in charge of Legal Department, DCP Nwodibo Ekechukwu.

Other members of the team include: DCP Chris Ezike of the Federal SARS, DCP Dan Mallam of the Monitoring Unit and DCP Adeyemi Ogunjemilusi of the Interpol Unit and others.

The statement further said that security had been tightened in all states of the federationon the orders of the IGP, particularly in the states perceived to be more vulnerable to terror attacks.

While appealing to all Nigerians, particularly Kaduna residents to remain calm, the IGP called on the citizens to cooperate with the security agencies by providing them with relevant information to solve the crime.

Although the details of their terms of reference were not given, security sources indicated that the police might be working on the assumption that the attackers might not be members of the Boko Haram sect.

According to the source, the police have not ruled out the possibility of some other groups masquerading the fluid situation in the country to seek to assassinate the former head of state.

Their position is informed by the fact that Buhari is hardly in the bad books of the Boko Haram insurgents, who had at a time allegedly elected to discuss with the authorities if Buhari could represent their interests.

Wednesday 23 July 2014

The 23-year-old will attempt to rebuild his career at the Britannia Stadium after having once been heralded as the next big thing alongside Argentina superstar Messi

The 23-year-old will attempt to rebuild his career at the Britannia Stadium after having once been heralded as the next big thing alongside Argentina superstar Messi
Can he do it on a wet and windy night in Stoke? That’s the question often asked – quite ridiculously – of Lionel Messi. Barcelona's brilliant forward has consistently proved himself on all terrains and in all climes, of course, yet the jury’s still out on his former Blaugrana team-mate.

It may seem strange now, but back in 2007, many Barca fans were as excited by Bojan as they were by Messi. Legend had it that the young striker had netted 1,000 goals for the club’s youth sides and it was believed that he would be their next big thing. Even better still, he was Catalan and hugely popular with the side’s supporters.

But it never quite happened for Bojan in the senior side. Restricted to substitute appearances, the striker scored 12, 10, 12 and seven in his four full seasons with the Catalan club, always on the periphery and never managing to hold down a starting spot. Lacking the strength to play as an orthodox No.9, the forward was not entirely comfortable as a winger either and never quite found his place in the great team coached by Pep Guardiola.
Bojan took a parting shot at Pep as he left in 2011. "I spent a long time without speaking to Guardiola," he said after moving to Italy. "I could not find the right words when I used to see him. I do not think I got what I deserved there."

But spells at Roma, AC Milan and Ajax proved equally frustrating and the 23-year-old now has just 66 goals to show from 280 career appearances – a far cry from his prolific performances for the Barca youth sides.

Hopes remained that Bojan would shine as he had done for the fist team but, for all his promise, Krkic has not hit the heights as expected since stepping up to the senior sides. And now, fairly or otherwise, he will be judged on how he does in the less cultured colours of Stoke.

"Anyone who knows European football will be aware of him as a player and the fact that he sees his future at Stoke City is really exciting and an endorsement of the club itself," Potters manager Mark Hughes said after sealing his signing. 

"He’s desperate to prove himself in the Premier League and we’re pleased to be able to offer him that platform."

But it is a long way from Camp Nou. Once Barca’s biggest talent alongside Messi, the 23-year-old now needs to prove himself at the much-maligned Premier League outfit. 

So while Leo licks his wounds after missing out on the World Cup this summer, Bojan finds himself looking to arrest an alarming slide since his debut back in 2007 – and how he fares on the wet and windy nights in Stoke will now hold the key to a future which once had looked so much brighter.

Tuesday 22 July 2014

Epigenetic map is a 'cellular memory'

Life's imprint on DNA now mappable in single cell
Epigenetic map is a 'cellular memory'
Epigenetic marks do not change the underlying DNA sequence, but they add extra instructions that do various things like silence certain genes and switch others on to differentiate a skin cell from a brain cell; they also alter gene behavior according to environmental conditions.



Thus, as well as DNA itself, there is an epigenetic map that acts as a kind of "cellular memory" of a cell's experience and response to environmental conditions.

This memory is preserved long after the condition in the environment that triggered it has faded. For example, a change in diet might result in a change in the epigenetic map and influence the long-term health of the organism.

Scientists are starting to realize that epigenetics research is as important to understanding health and disease as the study of the underlying DNA. But the tools to do this are not ideal. Researchers have had to rely on using mice as models for human early development, and tissue for analysis is very restricted.

New technique offers 'unprecedented ability to study epigenetic processes'
The ability to study the map of all the epigenetic marks of a person by using just a single cell is a significant step forward and gives researchers an "unprecedented ability to study epigenetic processes," explains corresponding author Dr. Gavin Kelsey, from the Babraham Institute:
"The ability to capture the full map of these epigenetic marks from individual cells will be critical for a full understanding of early embryonic development, cancer progression and aid the development of stem cell therapies."
The team expects such an application may potentially reduce the number of mice currently used for epigenetic research.

One of the chemical processes that produce epigenetic marks is called DNA methylation, where a methyl tag is attached to the DNA. The method the researchers describe in their paper treats the DNA with bisulfite to locate all the epigenetic methylation marks across the whole genome.

The treated DNA is then amplified and read using high-throughput gene sequencers that show the locations of the methylation marks and the genes affected.
For the first time, researchers can track what happens in individuals cells
Current methods look for epigenetic marks in groups of cells. This means trying to track what has happened in an individual cell is not clear. The new technique allows researchers to follow what happens in individual cells at a critical time in the early development of an embryo - when each cell has the potential to develop in a unique way.

Using their new technique, the team has already found many of the epigenetic marks that are different between cells are in places that control gene activity.

Dr. Kelsey says the proof-of-principle study shows that "large-scale, single-cell epigenetic analysis is achievable to help us understand how epigenetic changes control embryonic development."

"The application of single-cell approaches to epigenetic understanding goes far beyond basic biological research," he adds. "Future clinical applications could include the analysis of individual cancer cells to provide clinicians with the information to tailor treatments, and improvements in fertility treatment by understanding the potential for epigenetic errors in assisted reproduction technologies."

Funding for the study came from the BBSRC, the Medical Research Council (MRC), the Wellcome Trust, EU Blueprint and EU EpiGeneSys.

Medical News Today also recently learned how Stanford researchers have taken the first step in developing a tool that maps the origin of cancer from biological signatures. The team believes the tool, which traces the origin of certain types of cancer from the biological signature of their mutated cells, will help doctors decide the best treatments for their patients.

Thursday 17 July 2014

RNA and DNA Revealed: New Roles, New Rules

The New Genetics

RNA and DNA Revealed: New Roles, New Rules


For many years, when scientists thought about heredity, DNA was the first thing to come to mind. It's true that DNA is the basic ingredient of our genes and, as such, it often steals the limelight from RNA, the other form of genetic material inside our cells.

But, while they are both types of genetic material, RNA and DNA are rather different.
The chemical units of RNA are like those of DNA, except that RNA has the nucleotide uracil (U) instead of thymine (T). Unlike double-stranded DNA, RNA usually comes as only a single strand. And the nucleotides in RNA contain ribose sugar molecules in place of deoxyribose.
RNA is quite flexible—unlike DNA, which is a rigid, spiral-staircase molecule that is very stable. RNA can twist itself into a variety of complicated, three-dimensional shapes. RNA is also unstable in that cells constantly break it down and must continually make it fresh, while DNA is not broken down often. RNA's instability lets cells change their patterns of protein synthesis very quickly in response to what's going on around them.
Many textbooks still portray RNA as a passive molecule, simply a "middle step" in the cell's gene-reading activities. But that view is no longer accurate. Each year, researchers unlock new secrets about RNA. These discoveries reveal that it is truly a remarkable molecule and a multi-talented actor in heredity.
Today, many scientists believe that RNA evolved on the Earth long before DNA did. Researchers hypothesize—obviously, no one was around to write this down—that RNA was a major participant in the chemical reactions that ultimately spawned the first signs of life on the planet.

RNA World

At least two basic requirements exist for making a cell: the ability to hook molecules together and break them apart, and the ability to replicate, or copy itself, from existing information.

RNA probably helped to form the first cell. The first organic molecules, meaning molecules containing carbon, most likely arose out of random collisions of gases in the Earth's primitive atmosphere, energy from the Sun, and heat from naturally occurring radioactivity. Some scientists think that in this primitive world, RNA was a critical molecule because of its ability to lead a double life: to store information and to conduct chemical reactions. In other words, in this world, RNA served the functions of both DNA and proteins.
What does any of this have to do with human health? Plenty, it turns out.
Today's researchers are harnessing some of RNA's flexibility and power. For example, through a strategy he calls directed evolution, molecular engineer Ronald R. Breaker of Yale University is developing ways to create entirely new forms of RNA and DNA that both work as enzymes.
Breaker and others have also uncovered a hidden world of RNAs that play a major role in controlling gene activity, a job once thought to be performed exclusively by proteins. These RNAs, which the scientists named riboswitches, are found in a wide variety of bacteria and other organisms.
This discovery has led Breaker to speculate that new kinds of antibiotic medicines could be developed to target bacterial riboswitches.

Molecular Editor

Scientists are learning of another way to customize proteins: by RNA editing. Although DNA sequences spell out instructions for producing RNA and proteins, these instructions aren't always followed precisely. Editing a gene's mRNA, even by a single chemical letter, can radically change the resulting protein's function. Nature likely evolved the RNA editing function as a way to get more proteins out of the same number of genes. For example, researchers have found that the mRNAs for certain proteins important for the proper functioning of the nervous system are particularly prone to editing. It may be that RNA editing gives certain brain cells the capacity to react quickly to a changing environment.
Which molecules serve as the editor and how does this happen? Brenda Bass of the University of Utah School of Medicine in Salt Lake City studies one particular class of editors called adenosine deaminases. These enzymes "retype" RNA letters at various places within an mRNA transcript.

They do their job by searching for characteristic RNA shapes. Telltale twists and bends in folded RNA molecules signal these enzymes to change the RNA sequence, which in turn changes the protein that gets made.
Bass' experiments show that RNA editing occurs in a variety of organisms, including people. Another interesting aspect of editing is that certain disease-causing microorganisms, such as some forms of parasites, use RNA editing to gain a survival edge when living in a human host. Understanding the details of this process is an important area of medical research.

Healthy Interference

RNA controls genes in a way that was only discovered recently: a process called RNA interference, or RNAi. Although scientists identified RNAi less than 10 years ago, they now know that organisms have been using this trick for millions of years.
esearchers believe that RNAi arose as a way to reduce the production of a gene's encoded protein for purposes of fine-tuning growth or self-defense. When viruses infect cells, for example, they command their host to produce specialized RNAs that allow the virus to survive and make copies of itself. Researchers believe that RNAi eliminates unwanted viral RNA, and some speculate that it may even play a role in human immunity.

Oddly enough, scientists discovered RNAi from a failed experiment! Researchers investigating genes involved in plant growth noticed something strange: When they tried to turn petunia flowers purple by adding an extra "purple" gene, the flowers bloomed white instead.
This result fascinated researchers, who could not understand how adding genetic material could somehow get rid of an inherited trait. The mystery remained unsolved until, a few years later, two geneticists studying development saw a similar thing happening in lab animals.
The researchers, Andrew Z. Fire, then of the Carnegie Institution of Washington in Baltimore and now at Stanford University, and Craig Mello of the University of Massachusetts Medical School in Worcester, were trying to block the expression of genes that affect cell growth and tissue formation in roundworms, using a molecular tool called antisense RNA.
To their surprise, Mello and Fire found that their antisense RNA tool wasn't doing much at all. Rather, they determined, a double-stranded contaminant produced during the synthesis of the single-stranded antisense RNA interfered with gene expression. Mello and Fire named the process RNAi, and in 2006 were awarded the Nobel Prize in physiology or medicine for their discovery.
Further experiments revealed that the double-stranded RNA gets chopped up inside the cell into much smaller pieces that stick to mRNA and block its action, much like the microRNA pieces of Velcro discussed above (see drawing).
Today, scientists are taking a cue from nature and using RNAi to explore biology. They have learned, for example, that the process is not limited to worms and plants, but operates in humans too.
Medical researchers are currently testing new types of RNAi-based drugs for treating conditions such as macular degeneration, the leading cause of blindness, and various infections, including those caused by HIV and the herpes virus.

Dynamic DNA

A good part of who we are is "written in our genes," inherited from Mom and Dad. Many traits, like red or brown hair, body shape and even some personality quirks, are passed on from parent to offspring.
But genes are not the whole story. Where we live, how much we exercise, what we eat: These and many other environmental factors can all affect how our genes get expressed.
You know that changes in DNA and RNA can produce changes in proteins. But additional control happens at the level of DNA, even though these changes do not alter DNA directly. Inherited factors that do not change the DNA sequence of nucleotides are called epigenetic changes, and they too help make each of us unique.
Epigenetic means, literally, "upon" or "over" genetics. It describes a type of chemical reaction that can alter the physical properties of DNA without changing its sequence. These changes make genes either more or less likely to be expressed (see drawing).
Currently, scientists are following an intriguing course of discovery to identify epigenetic factors that, along with diet and other environmental influences, affect who we are and what type of illnesses we might get.

Secret Code


NA is spooled up compactly inside cells in an arrangement called chromatin. This packaging is critical for DNA to do its work. Chromatin consists of long strings of DNA spooled around a compact assembly of proteins called histones.
One of the key functions of chromatin is to control access to genes, since not all genes are turned on at the same time. Improper expression of growth-promoting genes, for example, can lead to cancer, birth defects or other health concerns.
Many years after the structure of DNA was determined, researchers used a powerful device known as an electron microscope to take pictures of chromatin fibers. Upon viewing chromatin up close, the researchers described it as "beads on a string," an image still used today. The beads were the histone balls, and the string was DNA wrapped around the histones and connecting one bead to the next.
Decades of study eventually revealed that histones have special chemical tags that act like switches to control access to the DNA. Flipping these switches, called epigenetic markings, unwinds the spooled DNA so the genes can be transcribed.
The observation that a cell's gene-reading machinery tracks epigenetic markings led C. David Allis, who was then at the University of Virginia Health Sciences Center in Charlottesville and now works at the Rockefeller University in New York City, to coin a new phrase, the "histone code." He and others believe that the histone code plays a major role in determining which proteins get made in a cell.
Flaws in the histone code have been associated with several types of cancer, and researchers are actively pursuing the development of medicines to correct such errors.

Battle of the Sexes

A process called imprinting, which occurs naturally in our cells, provides another example of how epigenetics affects gene activity.
With most genes, the two copies work exactly the same way. For some mammalian genes, however, only the mother's or the father's copy is switched on regardless of the child's gender. This is because the genes are chemically marked, or imprinted, during the process that generates eggs and sperm.

As a result, the embryo that emerges from the joining of egg and sperm can tell whether a gene copy came from Mom or Dad, so it knows which copy of the gene to shut off.
One example of an imprinted gene is insulin-like growth factor 2 (Igf2), a gene that helps a mammalian fetus grow. In this case, only the father's copy of Igf2 is expressed, and the mother's copy remains silent (is not expressed) throughout the life of the offspring.
Scientists have discovered that this selective silencing of Igf2 and many other imprinted genes occurs in all placental mammals (all except the platypus, echidna and marsupials) examined so far, but not in birds.
Why would nature tolerate a process that puts an organism at risk because only one of two copies of a gene is working? The likely reason, many researchers believe, is that mothers and fathers have competing interests, and the battlefield is DNA!
The scenario goes like this: It is in a father's interest for his embryos to get bigger faster, because that will improve his offspring's chances of survival after birth. The better an individual's chance of surviving infancy, the better its chance of becoming an adult, mating and passing its genes on to the next generation.
Of course mothers want strong babies, but unlike fathers, mothers provide physical resources to embryos during pregnancy. Over her lifetime, a female is likely to be pregnant several times, so she needs to divide her resources among a number of embryos in different pregnancies.
Researchers have discovered over 200 imprinted genes in mammals since the first one was identified in 1991. We now know that imprinting controls some of the genes that have an important role in regulating embryonic and fetal growth and allocating maternal resources. Not surprisingly, mutations in these genes cause serious growth disorders.
Marisa Bartolomei of the University of Pennsylvania School of Medicine in Philadelphia is trying to figure out how Igf2 and other genes become imprinted and stay silent throughout the life of an individual. She has already identified sequences within genes that are essential for imprinting. Bartolomei and other researchers have shown that these sequences, called insulators, serve as "landing sites" for a protein that keeps the imprinted gene from being transcribed.

Starting at the End

When we think of DNA, we think of genes. However, some DNA sequences are different: They don't encode RNAs or proteins. Introns

Another example is telomeres—the ends of chromosomes. There are no genes in telomeres, but they serve an essential function. Like shoelaces without their tips, chromosomes without telomeres unravel and fray. And without telomeres, chromosomes stick to each other and cause cells to undergo harmful changes like dividing abnormally.
Researchers know a good deal about telomeres, dating back to experiments performed in the 1970s by Elizabeth Blackburn, a basic researcher who was curious about some of the fundamental events that take place within cells.
At the time, Blackburn, now at the University of California, San Francisco, was working with Joseph Gall at Yale University. For her experimental system, she chose a single-celled, pond-dwelling organism namedTetrahymena. These tiny, pear-shaped creatures are covered with hairlike cilia that they use to propel themselves through the water as they devour bacteria and fungi.
Tetrahymena was a good organism for Blackburn's experiments because it has a large number of chromosomes—which means it has a lot of telomeres!
Her research was also perfectly timed, because methods for sequencing DNA were just being developed. Blackburn found that Tetrahymenastelomeres had an unusual nucleotide sequence: TTGGGG, repeated about 50 times per telomere.
Since then, scientists have discovered that the telomeres of almost all organisms have repeated sequences of DNA with lots of Ts and Gs. In human and mouse telomeres, for example, the repeated sequence is TTAGGG.
The number of telomere repeats varies enormously, not just from organism to organism but in different cells of the same organism and even within a single cell over time. Blackburn reasoned that the repeat number might vary if cells had an enzyme that added copies of the repeated sequence to the telomeres of some but not all chromosomes.
With her then-graduate student Carol Greider, now at Johns Hopkins University, Blackburn hunted for the enzyme. The team found it and Greider named it telomerase. Blackburn, Greider and Jack Szostak of Harvard Medical School in Boston shared the 2009 Nobel Prize in physiology or medicine for their discoveries about telomeres and telomerase.
As it turns out, the telomerase enzyme consists of a protein and an RNA component, which the enzyme uses as a template for copying the repeated DNA sequence.
What is the natural function of telomerase? As cells divide again and again, their telomeres get shorter. Most normal cells stop dividing when their telomeres wear down to a certain point, and eventually the cells die. Telomerase can counteract the shortening. By adding DNA to telomeres, telomerase rebuilds the telomere and resets the cell's molecular clock.
The discovery of telomerase triggered new ideas and literally thousands of new studies. Many researchers thought that the enzyme might play important roles in cancer and aging. Researchers were hoping to find ways to turn telomerase on so that cells would continue to divide (to grow extra cells for burn patients, for example), or off so that cells would stop dividing (to stop cancer, for instance).
So far, they have been unsuccessful. Although it is clear that telomerase and cellular aging are related, researchers do not know whether telomerase plays a role in the normal cellular aging process or in diseases like cancer.
Recently, however, Blackburn and a team of other scientists discovered that chronic stress and the perception that life is stressful affect telomere length and telomerase activity in the cells of healthy women. Blackburn and her coworkers are currently conducting a long-term, follow-up study to confirm these intriguing results.

The Other Human Genome

Before you think everything's been said about DNA, there's one little thing we didn't mention: Some of the DNA in every cell is quite different from the DNA that we've been talking about up to this point. This special DNA isn't in chromosomes—it isn't even inside the cell's nucleus where all the chromosomes are!

So where is this special DNA? It's inside mitochondria, the organelles in our cells that produce the energy-rich molecule adenosine triphosphate, or ATP. Mendel knew nothing of mitochondria, since they weren't discovered until late in the 19th century. And it wasn't until the 1960s that researchers discovered the mitochondrial genome, which is circular like the genomes of bacteria.
In human cells, mitochondrial DNA makes up less than 1 percent of the total DNA in each of our cells. The mitochondrial genome is very small—containing only about three dozen genes. These encode a few of the proteins that are in the mitochondrion, plus a set of ribosomal RNAs used for synthesizing proteins for the organelle.
Mitochondria need many more proteins though, and most of these are encoded by genes in the nucleus. Thus, the energy-producing capabilities of human mitochondria—a vital part of any cell's everyday health—depend on coordinated teamwork among hundreds of genes in two cellular neighborhoods: the nucleus and the mitochondrion.
Mitochondrial DNA gets transcribed and the RNA is translated by enzymes that are very different from those that perform this job for genes in our chromosomes. Mitochondrial enzymes look and act much more like those from bacteria, which is not surprising because mitochondria are thought to have descended from free-living bacteria that were engulfed by another cell over a billion years ago.
Scientists have linked mitochondrial DNA defects with a wide range of age-related diseases including neurodegenerative disorders, some forms of heart disease, diabetes and various cancers. It is still unclear, though, whether damaged mitochondria are a symptom or a cause of these health conditions.
Scientists have studied mitochondrial DNA for another reason: to understand the history of the human race. Unlike our chromosomal DNA, which we inherit from both parents, we get all of our mitochondrial DNA from our mothers.
Thus, it is possible to deduce who our maternal ancestors were by tracking the inheritance of mutations in mitochondrial DNA. For reasons that are still not well understood, mutations accumulate in mitochondrial DNA more quickly than in chromosomal DNA. So, it's possible to trace your maternal ancestry way back beyond any relatives you may know by name—all the way back to "African Eve," the ancestor of us all!


Friday 11 July 2014

Cowpea

Resarch on Cowpea
Cowpea (Vigna unguiculata (L.) Walp.) is of vital importance to the livelihoods of millions of people in the semi-arid regions of West and Central Africa. It is the most important grain legume crop in sub-Saharan Africa. Cowpea is mostly grown by smallholders in the hot, drought-prone savannas and very arid Sahelian agro-ecological zones, often intercropped with pearl millet and sorghum. Cowpea is a protein-rich grain that complements staple cereal and starchy tuber crops. It also provides fodder for livestock, improves the soil by fixing nitrogen, and benefits households by bringing in cash and diversifying sources of income. The sale of cowpea stems and leaves for animal feed during the dry season provides vital household income.
Origin and use

Cowpea originated and was domesticated in Southern Africa and later spread to East and West Africa and Asia.

The crop can be harvested at three stages: when the pods are young and green, when the pods are mature and green, and when the pods are dry. The young leaves, immature pods, immature seeds, and the mature dried seeds are all used as food. The stems, leaves, and vines serve as animal feed and are often stored for use during the dry season. In Nigeria, farmers who cut and store cowpea fodder for sale at the peak of the dry season increase their annual income by 25%. Women prepare and sell snacks made from cowpea, and are also mainly involved in the sale of green pods.

Fifty-two percent of Africa’s production is used for food, 13% as animal feed, 10% for seed, 9% for other uses, and 16% is wasted.
Production

An estimated 14.5 million hectares of land is planted to cowpea each year worldwide. Global production of dried cowpeas in 2010 was 5.5 million metric tons; Africa was responsible for 94% of this. Nigeria is the largest producer and consumer of cowpea, producing 2.2 million metric tons of dried grain in 2010. Niger is the second largest producer, followed by Burkina Faso, Myanmar, Cameroon, and Mali. The average yield worldwide is estimated at 450 kilograms per hectare, the lowest of the major tropical grain legumes. An estimated 38 million households (194 million people) grow cowpea in sub-Saharan Africa, but productivity has not seen sustained growth over the last two decades – total area, yield, and production grew by 4.3%, 1.5%, and 5.8%, respectively.
Nutrition

The grain contains 25% protein, and several vitamins and minerals.
Impact of CGIAR Centers

The net present value of benefits from investment in cowpea research and extension by the International Institute of Tropical Agriculture (IITA) over 20 years is estimated at upwards of US$1.09 billion with an internal rate of return of between 50 and 103%.

In the semi-arid region of West and Central Africa, farmers traditionally cultivate different cowpea varieties for grain and fodder. In the early 1990s, IITA, in collaboration with the International Livestock Research Institute (ILRI), developed improved cowpea varieties that produce both grain for human consumption and fodder for livestock during the dry season. The diffusion and uptake of one of these varieties in Kano State, Nigeria, was very impressive. By 1997, only four years after its accidental release to one farmer, it had reached over 1,500 farmers. Farmers found that adopting this dry-season, dual-purpose cowpea brought many benefits. These include food security during a critical period of the year, cash income, crop diversification, fodder, and in situ grazing after harvesting, in periods when the prices of cowpea grain peak, and when good quality fodder is scarce. These dual-purpose cowpea varieties are now being widely adopted in the dry savannas of West Africa, with estimated benefits of between US$299 million and US$1.1 billion expected to accrue from 2000 to 2020.

Cowpea production and processing is propelling a silent revolution in Nigeria, as incomes from the crop improve rural livelihoods. Processing cowpea is almost exclusively undertaken by women. They produce a range of products that are sold as street food, including moin-moin (ground cowpea mixed with other ingredients and boiled or steamed to make a meat substitute), and akara, a deep-fat fried fritter – the most popular of the cowpea-based food products.

“The benefits are many,” says Mrs. Olaiya Oluwakemi, an akara vendor in Osu, a community in southwestern Nigeria, “From frying of akara alone, I have been able to afford to send my son to university. I built a house and now own a car.” Her business has grown in the last seven years and she currently employs more than 20 people. On average, she makes a profit of US$10–13 a day.

Elsewhere in northern Nigeria, home to cowpea production, the crop is improving the livelihoods of farmers. Cowpea farmers using improved cowpea varieties and management practices have seen their incomes increase by on average 55%. Besides improving incomes, interventions by IITA and its partners are helping farmers with improved technologies to meet the increasing demand for the crop.

Wednesday 9 July 2014

Java

Reserved words

Like any programming language, the Java language designates certain words that the compiler recognizes as special, and as such you are not allowed to use them for naming your Java constructs. The list of reserved words is surprisingly short 
    abstract
    assert
    boolean
    break
    byte
    case
    catch
    char
    class
    const
    continue
    default
    do
    double
    else
    enum
    extends
    final
    finally
    float
    for
    goto
    if
    implements
    import
    instanceof
    int
    interface
    long
    native
    new
    package
    private
    protected
    public
    return
    short
    static
    strictfp
    super
    switch
    synchronized
    this
    throw
    throws
    transient
    try
    void
    volatile
    while

Note that true, false, and null are technically not reserved words. Although they are literals, I included them in this list because you can't use them to name Java constructs.

One advantage of programming with an IDE is that it can use syntax coloring for reserved words, as you'll see later in this tutorial.
Structure of a Java object

Remember that an object is a discrete entity that contains attributes and behavior. That means that it has a crisp boundary and a state and can do things when correctly asked. Every object-oriented language has rules about how to define an object.

In the Java language, objects are defined as demonstrated in Listing 1:
Listing 1. Object definition

package packageName;
import ClassNameToImport;
accessSpecifier class ClassName {
  accessSpecifier dataType variableName [= initialValue];
  accessSpecifier ClassName([argumentList]) {
    constructorStatement(s)
  }
  accessSpecifier returnType methodName([argumentList]) {
    methodStatement(s)
  }
  // This is a comment
  /* This is a comment too */
  /* This is a
     multiline
     comment */
}

Listing 1 contains various types of constructs, which I've differentiated with font formatting. The constructs shown in bold (which you'll find in the list of reserved words) are literals; in any object definition, they must be exactly what they are here. The names that I've given the other constructs describe the concepts they represent. I'll explain all of the constructs in detail in the rest of this section.

Note: In Listing 1 and some other code examples in this section, square brackets indicate that the constructs within them are not required. The brackets themselves (unlike { and }) are not part of the Java syntax.
Comments in code

Notice that Listing 1 also includes some comment lines:

  // This is a comment
  /* This is a comment too */
  /* This is a
     multiline
     comment */

Just about every programming language allows the programmer to add comments to help document the code. Java syntax allows for both single-line and multiline comments. A single-line comment must be contained on one line, although you can use adjacent single-line comments to form a block. A multiline comment begins with /*, must be terminated with */, and can span any number of lines.

You'll learn more about comments when you get to this tutorial's Writing good Java code section.
Packaging objects

The Java language lets you choose the names for your objects, such as Account, Person, or LizardMan. At times, you may end up using the same name to express two slightly different concepts. This is called a name collision, and it happens frequently. The Java language uses packages to resolve these conflicts.

A Java package is a mechanism for providing a namespace: an encapsulated area in which names are unique, but outside of which they might not be. To identify a construct uniquely, you must fully qualify it by including its namespace.

Packages also give you a nice way to build more complex applications into discrete units of functionality.
Package definition

To define a package, you use the package keyword followed by a legal package name, terminated with a semicolon. Often package names are separated by dots, and follow this de facto scheme:

package orgType.orgName.appName.compName;

This package definition breaks down like so:

    orgType is the organization type such as com, org, or net.
    orgName is the name of the organization's domain, such as makotogroup, sun, or ibm.
    appName is the name of the application, abbreviated.
    compName is the name of the component.

The Java language doesn't force you to follow this package convention. In fact, you don't need to specify a package at all, in which case all of your objects must have unique class names and will reside in the default package. As a best practice, I recommend that you define all of your Java classes in packages. You'll follow that convention throughout this tutorial.
Import statements

Up next in the object definition (referring back to Listing 1) is the import statement. An import statement tells the Java compiler where to find classes you reference inside of your code. Any nontrivial object uses other objects for some functionality, and the import statement is how you tell the Java compiler about them.

An import statement usually looks like this:

import ClassNameToImport;

You specify the import keyword followed by the class that you want to import followed by a semicolon. The class name should be fully qualified, meaning it should include its package.

To import all classes within a package, you can put .* after the package name. For example, this statement imports every class in the com.makotogroup package:

import com.makotogroup.*;

Importing an entire package can make your code less readable, however, so I recommend that you import just the classes you need.
Eclipse simplifies imports

When writing code in the Eclipse editor, you can type the name of a class you want to use, followed by Ctrl+Shift+O. Eclipse figures out which imports you need and adds them automatically. If Eclipse finds two classes with the same name, it displays a dialog box asking you which class you want to add imports for.
Class declaration

In order to define an object in the Java language, you must declare a class. Think of a class as a template for an object, like a cookie cutter. The class defines the object's basic structure, and at run time your application creates an instance of the object. The word object is often used synonymously with the word class. Strictly speaking, a class defines the structure of a thing of which the object is an instance.

Listing 1 includes this class declaration:

accessSpecifier class ClassName {
  accessSpecifier dataType variableName [= initialValue];
  accessSpecifier ClassName([argumentList]) {
    constructorStatement(s)
  }
  accessSpecifier returnType methodName([argumentList]) {
    methodStatement(s)
  }
}

A class's accessSpecifier could have several values, but most of the time it is public. You'll look at other values of accessSpecifier soon.
Class-naming conventions

You can name classes pretty much however you want, but the convention is to use CamelCase: start with a capital letter, capitalize the first letter of each concatenated word, and make all the other letters lowercase. Class names should contain only letters and numbers. Sticking to these guidelines will ensure that your code is more accessible to other developers following the same conventions.

Classes can have two types of members: variables and methods.
Variables

The values of a given class's variables distinguish each instance of that class and define its state. These values are often referred to as instance variables. A variable has:

    An accessSpecifier
    A dataType
    A variableName
    Optionally, an initialValue

The possible accessSpecifier values are:
Public variables

It's never a good idea to use public variables, but in extremely rare cases it could be necessary, so the option exists. The Java platform doesn't constrain your use cases, so it's up to you to be disciplined about using good coding conventions, even if tempted to do otherwise.

    public: Any object in any package can see the variable. (Don't ever use this value.)
    protected: Any object defined in the same package, or a subclass (defined in any package), can see the variable.
    No specifier (also called friendly or package private access): Only objects whose classes are defined in the same package can see the variable.
    private: Only the class containing the variable can see it.

A variable's dataType depends on what the variable is — it could be a primitive type or another class type (again, more about this later).

The variableName is up to you, but by convention variable names use the CamelCase convention I described earlier, except that they begin with a lowercase letter. (This style is sometimes called lowerCamelCase.)

Don't worry about the initialValue for now; just know that you can initialize an instance variable when you declare it. (Otherwise, the compiler generates a default for you that will be set when the class is instantiated.)
Example: Class definition for Person

Before moving on to methods, here's an example that summarizes what you've learned so far. Listing 2 is a class definition for Person:
Listing 2. Basic class definition for Person

package com.makotogroup.intro;

public class Person {
  private String name;
  private int age;
  private int height;
  private int weight;
  private String eyeColor;
  private String gender;
}

The basic class definition for Person isn't very useful at this point because it defines only its attributes (and private ones at that).

To be more interesting, the Person class needs behavior — and that means methods.
Methods

A class's methods define its behavior. Sometimes this behavior is nothing more than to return the current value of an attribute. Other times, the behavior can be quite complex.

There are essentially two categories of methods: constructors and all other methods — of which there are many types. A constructor method is used only to create an instance of a class. Other types of methods can be used for virtually any application behavior.

Looking back at Listing 1, it shows the way to define the structure of a method, which includes things like:

    accessSpecifier
    returnType
    methodName
    argumentList

The combination of these structural elements in a method's definition is called its signature.

Next you'll look in more detail at the two types of methods, starting with constructors.
Constructor methods

Constructors let you specify how to instantiate a class. Listing 1 shows the constructor declaration syntax in abstract form; here it is again in Listing 3:
Listing 3. Constructor declaration syntax

accessSpecifier ClassName([argumentList]) {
  constructorStatement(s)
}

Constructors are optional

If you don't provide a constructor, the compiler will provide one for you, called the default (or no-argument) constructor. If you provide a constructor other than a no-argument (or no-arg) constructor, the compiler will not generate one for you.

A constructor's accessSpecifier is the same as for variables. The name of the constructor must match the name of the class. So if you call your class Person, then the name of the constructor must also be Person.

For any constructor other than the default constructor, you pass an argumentList, which is one or more of:

argumentType argumentName

Arguments in an argumentList are separated by commas, and no two arguments can have the same name. argumentType is either a primitive type or another class type (the same as with variable types).
Class definition with a constructor

Now you'll see what happens when you add the capability to create a Person object in two ways: by using a no-arg constructor and by initializing a partial list of attributes.

Listing 4 shows how to create constructors and also how to use argumentList:
Listing 4. Person class definition with a constructor

package com.makotogroup.intro;
public class Person {
  private String name;
  private int age;
  private int height;
  private int weight;
  private String eyeColor;
  private String gender;
  public Person() {
    // Nothing to do...
  }
 
public Person(String name, int age, int height, String eyeColor, String gender) {
    this.name = name;
    this.age = age;
    this.height = height;
    this.weight = weight;
    this.eyeColor = eyeColor;
    this.gender = gender;
  }
}

Note the use of the this keyword in making the variable assignments in Listing 4. This is Java shorthand for "this object" and must be used when referencing two variables with the same name (as in this case where age, for example, is both a constructor parameter and a class variable), and helps the compiler disambiguate the reference.

The Person object is getting more interesting, but it needs more behavior. And for that, you need more methods.
Other methods

A constructor is a particular kind of method with a particular function. Similarly, many other types of methods perform particular functions in Java programs. Exploration of other methods begins in this section and continues throughout the tutorial.

Back in Listing 1, I showed you how to declare a method:

accessSpecifier returnType methodName([argumentList]) {
  methodStatement(s)
}

Other methods look much like constructors, with a couple of exceptions. First, you can name other methods whatever you like (though, of course, there are rules). I recommend the following conventions:

    Start with a lowercase letter.
    Avoid numbers unless absolutely necessary.
    Use only alphabetic characters.

Second, unlike constructors, other methods have an optional return type.
Person's other methods

Armed with this basic information, you can see in Listing 5 see what happens when you add a few more methods to the Person object. (I've omitted constructors for brevity.)
Listing 5. Person with a few new methods

package com.makotogroup.intro;

public class Person {
  private String name;
  private int age;
  private int height;
  private int weight;
  private String eyeColor;
  private String gender;

  public String getName() { return name; }
  public void setName(String value) { name = value; }
  // Other getter/setter combinations...
}

Notice the comment in Listing 5 about "getter/setter combinations." You''ll work more with getters and setters later in the tutorial. For now, all you need to know is that a getter is a method for retrieving the value of an attribute, and a setter is a method for modifying that value. I've shown only one getter/setter combination (for the Name attribute), but you could define more in a similar fashion.

Note in Listing 5 that if a method doesn't return a value, you must tell the compiler by specifying the void return type in its signature.
Static and instance methods

There are generally two types of (nonconstructor) methods: instance methods and static methods. Instance methods are dependent on the state of a specific object instance for their behavior. Static methods are also sometimes called class methods, because their behavior is not dependent on any single object's state. A static method's behavior happens at the class level.

Static methods are used largely for utility; you can think of them as a way of having global methods (à la C) while keeping the code itself grouped with the class that needs it.

For example, throughout this tutorial you'll use the JDK Logger class to output information to the console. To create a Logger class instance, you don't instantiate a Logger class; instead, you invoke a static method called getLogger().

The syntax for invoking a static method is different from the syntax used to invoke a method on an object instance. You also use the name of the class that contains the static method, as shown in this invocation:

Logger l = Logger.getLogger("NewLogger");

So to invoke a static method, you don't need an object instance, just the name of the class.

Your first Java object

It's time to pull together what you've learned in the previous sections and start writing some code. This section walks you through declaring a class and adding variables and methods to it using the Eclipse Package Explorer. You'll learn how to use the Logger class to keep an eye on your application's behavior, and also how to use a main() method as a test harness.
Creating a package

If you're not already there, get to the Package Explorer perspective in Eclipse. You're going to get set up to create your first Java class. The first step is to create a place for the class to live. Packages are namespace constructs, but they conveniently map directly to the file system's directory structure as well.

Rather than use the default package (almost always a bad idea), you'll create one specifically for the code you'll be writing. Click File > New > Package to bring up the Java Package wizard, shown in Figure 4:
Figure 4. The Eclipse Java Package wizard
The Eclipse Package Wizard.

Type com.makotogroup.intro into the Name text box and click Finish. You will see the new package created in the Package Explorer.
Declaring the class

There's more than one way to create a class from the Package Explorer, but the easiest way is to right-click on the package you just created and choose New > Class.... You will see the New Class dialog box.

In the Name text box, type Person. Under Which method stubs would you like to create?, check public static void main(String[] args). (You'll see why shortly.) Next, click Finish.

The new class appears in your edit window. I recommend closing a few of the views from their default appearance to make it easier to see your source code, as shown in Figure 5:
Figure 5. A well-ordered workspace
The Eclipse Package wizard's edit window.

Eclipse generates a shell class for you and includes the package statement at the top, along with the main() method you asked for and the comments you see. You just need to flesh out the class now. You can configure how Eclipse generates new classes via Window > Preferences > Java > Code Style > Code Templates. For simplicity, you'll go with Eclipse's out-of-the-box code generation.

In Figure 5, notice the asterisk (*) next to the new source-code file, indicating that I've made a modification. And notice that the code is unsaved. Next, notice that I made a mistake when declaring the Name attribute: I declared Name's type to be Strin. The compiler could not find a reference to such a class and flagged it as a compile error (that's the wavy red line underneath Strin). Of course, I can fix my mistake by adding a g to the end of Strin. This is just a small demonstration of the power of an IDE over using command-line tools for software development.
Adding class variables

In Listing 4, you began to flesh out the Person class, but I didn't explain much of the syntax. Now I'll formally define how to add class variables.

Recall that a variable has an accessSpecifier, a dataType, a variableName, and, optionally, an initialValue. Earlier, you looked briefly at how to define the accessSpecifier and variableName. Now you'll see the dataType that a variable can have.

A dataType can be either a primitive type or a reference to another object. For example, notice that Age is an int (a primitive type), and Name is a String (an object). The JDK comes packed full of useful classes like java.lang.String, and those in the java.lang package do not need to be imported (a shorthand courtesy of the Java compiler). But whether the dataType is a JDK class such as String or a user-defined class, the syntax is essentially the same.

Table 1 shows the eight primitive data types you're likely to see on a regular basis, including the default values that primitives take on if you do not explicitly initialize a member variable's value:
Table 1. Primitive data types
Type    Size    Default value    Range of values
boolean    n/a    false    true or false
byte    8 bits    0    -128 to 127
char    16 bits    (unsigned)    \u0000' \u0000' to \uffff' or 0 to 65535
short    16 bits    0    -32768 to 32767
int    32 bits    0    -2147483648 to 2147483647
long    64 bits    0    -9223372036854775808 to 9223372036854775807
float    32 bits    0.0    1.17549435e-38 to 3.4028235e+38
double    64 bits    0.0    4.9e-324 to 1.7976931348623157e+308
Built-in logging

Before going further into coding, you need to know how your programs tell you what they are doing.

The Java platform includes the java.util.logging package, a built-in logging mechanism for gathering program information in a readable form. Loggers are named entities that you create through a static method call to the Logger class, like so:

import java.util.logging.Logger;
//. . .
Logger l = Logger.getLogger(getClass().getName());

When calling the getLogger() method, you pass it a String. For now, just get in the habit of passing the name of the class the code you're writing is located in. From any regular (that is, nonstatic) method, the code above will always reference the name of the class and pass that to the Logger.

If you are making a Logger call inside of a static method, just reference the name of the class you're inside of:

Logger l = Logger.getLogger(Person.class.getName());

In this example, the code you're inside of is the Person class, so you reference a special literal called class that retrieves the Class object (more on this later) and gets its Name attribute.

This tutorial's Writing good Java code section includes a tip on how not to do logging.
Using main() as a test harness

main() is a special method that you can include in any class so that the JRE can execute its code. A class is not required to have a main() method — in fact, most never will — and a class can have at most one main() method.

main() is a handy method to have because it gives you a quick test harness for the class. In enterprise development, you would use test libraries, but for the purpose of this tutorial, you will use main() as your test harness.

Go into the Eclipse source code editor for Person and add code to make it look like Listing 4. Eclipse has a handy code generator to generate getters and setters (among other things). To try it out, put your mouse caret on the Person class definition (that is, on the word Person in the class definition), and go to Source > Generate Getters and Setters.... When the dialog box opens, click Select All, as shown in Figure 6:
Figure 6. Eclipse generating getters and setters
Eclipse generating getters and setters.

For the insertion point, choose Last member and click OK. Notice that the getters and setters appear after the main() method.
There's more to main()

Now you'll add some code to main() to allow you to instantiate a Person, set a few attributes, and then print those to the console.

Start by adding a constructor to Person. Type the code in Listing 6 into your source window just below the top part of the class definition (the line immediately beneath public class Person ()):
Listing 6. Person constructor

public Person(String name, int age, int height, int weight, String eyeColor,
                String gender) {
    this.name = name;
    this.age = age;
    this.height = height;
    this.weight = weight;
    this.eyeColor = eyeColor;
    this.gender = gender;
  }

Make sure you have no wavy lines indicating compile errors.

Next, go into the main() method and make it look like Listing 7:
Listing 7. The main() method

public static void main(String[] args) {
  Person p = new Person("Joe Q Author", 42, 173, 82, "Brown", "MALE");
  Logger l = Logger.getLogger(Person.class.getName());
  l.info("Name: " + p.getName());
  l.info("Age:" + p.getAge());
  l.info("Height (cm):" + p.getHeight());
  l.info("Weight (kg):" + p.getWeight());
  l.info("Eye Color:" + p.getEyeColor());
  l.info("Gender:" + p.getGender());
}

Don't worry about the Logger class for now. Just enter the code as you see it in Listing 7. You're now ready to run your first Java program.
Executing code in Eclipse

To run a Java application from inside Eclipse, select the class you want to run, which must have a main() method. Currently, you have only one class — and it does have a main() method — so select Person, then click the Run icon (which is green and has a small triangular arrow pointing to the right). When asked, select to run Person as a Java application, then sit back and watch it go. You should see something like the screenshot in Figure 7:
Figure 7. See Person run
Eclipse running Person as a Java application.

Notice that the Console view opens automatically and shows Logger output. I have also selected the Outline view in the left-hand pane, which reveals the basic structure of the Person class at a glance.

Back to top
Adding behavior to a Java object

Person is looking good so far, but it could use some additional behavior to make it more interesting. As you've already learned, creating behavior means adding methods. This section looks more closely at accessor methods — namely, the getters and setters you've already seen in action. You'll also learn syntax for calling methods.
Accessor methods

In order to encapsulate a class's data from other objects, you declare its variables to be private and then provide accessor methods. As you know, a getter is an accessor method for retrieving the value of an attribute; a setter is an accessor method for modifying that value. The naming of accessors follows a strict convention known as the JavaBeans pattern, whereby any attribute Foo has a getter called getFoo() and a setter called setFoo().

The JavaBeans pattern is so common that support for it is built right into the Eclipse IDE. You've even already seen it in action — when you generated getters and setters for Person in the preceding section.

Accessors follow these guidelines:

    The attribute itself is always declared with private access.
    The access specifier for getters and setters is public.
    Getters don't take any parameters and return a value whose type is the same as the attribute it accesses.
    Settings only take one parameter, of the type of the attribute, and do not return a value.

Declaring accessors

By far the easiest way to declare accessors is to let Eclipse do it for you, as shown back in Figure 6. But you should also know how to hand-code a getter-and-setter pair. Suppose you have an attribute, Foo, whose type is java.lang.String. A complete declaration for it (following the accessor guidelines) would be:

private String foo;
public String getFoo() {
  return foo;
}
public void setFoo(String value) {
  foo = value;
}

You may notice right away that the parameter value passed to the setter is named differently than if it had been generated by Eclipse. This is my own convention, and one I recommend to other developers. On the rare occasion that I do hand-code a setter, I always use the name value as the parameter value to the setter. This eye-catcher reminds that I've hand-coded the setter. Because I usually allow Eclipse to generate getters and setters for me, when I don't there's a good reason for it. Using value as the setter's parameter value reminds me that this setter is special. (Code comments could also do that.)
Calling methods

Invoking, or calling, methods is easy. You saw in Listing 7 how to invoke the various getters of Person to return their values. Now I'll formalize the mechanics of making method calls.
Method invocation with and without parameters

To invoke a method on an object, you need a reference to that object. Method-invocation syntax comprises the object reference, a literal dot, the method name, and any parameters that need to be passed:

objectReference.someMethod();
objectReference.someOtherMethod(parameter);

Here is a method invocation without parameters:

Person p = /*obtain somehow */;
p.getName();

And here is a method invocation with parameters (accessing the Name attribute of Person):

Person p = new Person("Joe Q Author", 42, 173, 82, "Brown", "MALE");

Remember that constructors are methods, too. And you can separate the parameters with spaces and newlines. The Java compiler doesn't care. These next two method invocations are identical:

new Person("Joe Q Author", 42, 173, 82, "Brown", "MALE");

new Person("Joe Q Author",
        42,
        173,
        82,
        "Brown",
        "MALE");

Nested method invocation

Method invocations can also be nested:

Logger l = Logger.getLogger(Person.class.getName());
l.info("Name: " + p.getName());

Here you are passing the return value of Person.class.getName() to the getLogger() method. Remember that the getLogger() method call is a static method call, so its syntax differs slightly. (You don't need a Logger reference to make the invocation; instead, you just use the name of the class itself as the left-hand side of the invocation.)

That's really all there is to method invocation.

Back to top
Strings and operators

The tutorial has so far introduced several variables of type String, but without much explanation. Learn more about strings in this section, and also find out when and how to use operators.
Strings

Handling strings in C is labor-intensive because they're null-terminated arrays of 8-bit characters that you have to manipulate. In the Java language, strings are first-class objects of type String, with methods that help you manipulate them. (The closest Java code gets to the C world with regard to strings is the char primitive data type, which can hold a single Unicode character, such as a.)

You've already seen how to instantiate a String object and set its value (back in Listing 5), but there are several other ways to do that. Here are a couple of ways to create a String instance with a value of hello:

String greeting = "hello";

greeting = new String("hello");

Because Strings are first-class objects in the Java language, you can use new to instantiate them. Setting a variable of type String has the same result, because the Java language creates a String object to hold the literal, then assigns that object to the instance variable.
Concatenating strings

You can do many things with String, and the class has many helpful methods. Without even using a method, you've already done something interesting with two Strings by concatenating, or combining, them:

l.info("Name: " + p.getName());

The plus (+) sign is shorthand for concatenating Strings in the Java language. (There is a performance penalty for doing this type of concatenation inside a loop, but for now you don't need to worry about it.)
Concatenation example

Let's try concatenating Strings inside of the Person class. At this point, you have a name instance variable, but it would be nice to have a firstName and lastName. You could then concatenate them when another object requests Person's full name.

The first thing you need to do is add the new instance variables (at the same location in the source code where name is currently defined):

//private String name;
private String firstName;
private String lastName;

You don't need name anymore; you've replaced it with firstName and lastName.
Chaining method calls

Now you can generate getters and setters for firstName and lastName (as shown back in Figure 6), remove the setName() method, and change getName() to look like this:

public String getName() {
  return firstName.concat(" ").concat(lastName);
}

This code illustrates chaining of method calls. This is a technique commonly used with immutable objects like String, where a modification to an immutable object always returns the modification (but doesn't change the original). You then operate on the returned, changed value.
Operators

As you might expect, the Java language can do arithmetic, and you've already seen how to assign variables. Now I'll give you a brief look at some of the Java language operators you'll need as your skills improve. The Java language uses two types of operators:

    Unary: Only one operand is needed.
    Binary: Two operands are needed.

The Java language's arithmetic operators are summarized in Table 2:
Table 2. Java language's arithmetic operators
Operator    Usage    Description
+    a + b    Adds a and b
+    +a    Promotes a to int if it's a byte, short, or char
-    a - b    Subtracts b from a
-    -a    Arithmetically negates a
*    a * b    Multiplies a and b
/    a / b    Divides a by b
%    a % b    Returns the remainder of dividing a by b (the modulus operator)
++    a++    Increments a by 1; computes the value of a before incrementing
++    ++a    Increments a by 1; computes the value of a after incrementing
--    a--    Decrements a by 1; computes the value of a before decrementing
--    --a    Decrements a by 1; computes the value of a after decrementing
+=    a += b    Shorthand for a = a + b
-=    a -= b    Shorthand for a = a - b
*=    a *= b    Shorthand for a = a * b
%=    a %= b    Shorthand for a = a % b
Additional operators

In addition to the operators in Table 2, you've seen several other symbols that are called operators in the Java language. For instance:

    Period (.), which qualifies names of packages and invokes methods
    Parentheses (()), which delimit a comma-separated list of parameters to a method
    new, which (when followed by a constructor name) instantiates an object

The Java language syntax also includes a number of operators that are used specifically for conditional programming; that is, programs that respond differently based on different input. You'll look at those in the next section.

Back to top
Conditional operators and control statements

In this section, learn about the various statements and operators you'll use to tell your Java programs how you want them to act based on different input.
Relational and conditional operators

The Java language gives you operators and control statements that let you make decisions in your code. Most often, a decision in code starts with a boolean expression (that is, one that evaluates to either true or false). Such expressions use relational operators, which compare one operand or expression to another, and conditional operators.

Table 3 lists the relational and conditional operators of the Java language:
Table 3. Relational and conditional operators
Operator    Usage    Returns true if ...
>    a > b    a is greater than b
>=    a >= b    a is greater than or equal to b
<    a < b    a is less than b
<=    a <= b    a is less than or equal to b
==    a == b    a is equal to b
!=    a != b    a is not equal to b
&&    a && b    a and b are both true, conditionally evaluates b (if a is false, b is not evaluated)
||    a || b    a or b is true, conditionally evaluates b (if a is true, b is not evaluated)
!    !a    a is false
&    a & b    a and b are both true, always evaluates b
|    a | b    a or b is true, always evaluates b
^    a ^ b    a and b are different
The if statement

Now that you have a bunch of operators, it's time to use them. This code shows what happens when you add some logic to the Person object's getHeight() accessor:

public int getHeight() {
  int ret = height;
  // If locale of the machine this code is running on is U.S.,
  if (Locale.getDefault().equals(Locale.US))
    ret /= 2.54;// convert from cm to inches
  return ret;
}

If the current locale is in the United States (where the metric system is not in use), then it might make sense to convert the internal value of height (in centimeters) to inches. This example illustrates the use of the if statement, which evaluates a boolean expression inside parentheses. If that expression evaluates to true, it executes the next statement.

In this case, you only need to execute one statement if the Locale of the machine the code is running on is Locale.US. If you need to execute more than one statement, you can use curly braces to form a compound statement. A compound statement groups many statements into one — and compound statements can also contain other compound statements.
Variable scope

Every variable in a Java application has scope, or localized namespace, where you can access it by name within the code. Outside that space the variable is out of scope, and you will get a compile error if you try to access it. Scope levels in the Java language are defined by where a variable is declared, as shown in Listing 8:
Listing 8. Variable scope

public class SomeClass {

  private String someClassVariable;
  public void someMethod(String someParameter) {
    String someLocalVariable = "Hello";
    if (true) {
      String someOtherLocalVariable = "Howdy";
    }
    someClassVariable = someParameter; // legal
    someLocalVariable = someClassVariable; // also legal
    someOtherLocalVariable = someLocalVariable;// Variable out of scope!
  }
  public void someOtherMethod() {
    someLocalVariable = "Hello there";// That variable is out of scope!
  }
}

Within SomeClass, someClassVariable is accessible by all instance (that is, nonstatic) methods. Within someMethod, someParameter is visible, but outside of that method it is not, and the same is true for someLocalVariable. Within the if block, someOtherLocalVariable is declared, and outside of that if block it is out of scope.

Scope has many rules, but Listing 8 shows the most common ones. Take a few minutes to familiarize yourself with them.
The else statement

There are times in a program's control flow when you want to take action only if a particular expression fails to evaluate to true. That's when else comes in handy:

public int getHeight() {
  int ret;
  if (gender.equals("MALE"))
    ret = height + 2;
  else {
    ret = height;
    Logger.getLogger("Person").info("Being honest about height...");
  }
  return ret;
}

The else statement works the same way as if, in that it executes only the next statement it runs across. In this case, two statements are grouped into a compound statement (notice the curly braces), which the program then executes.

You can also use else to perform an additional if check, like so:

if (conditional) {
  // Block 1
} else if (conditional2) {
  // Block 2
} else if (conditional3) {
  // Block 3
} else {

  // Block 4
} // End

If conditional evaluates to true, then Block 1 is executed and the program jumps to the next statement after the final curly brace (which is indicated by // End). If conditional does not evaluate to true, then conditional2 is evaluated. If it is true, then Block 2 is executed, and the program jumps to the next statement after the final curly brace. If conditional2 is not true, then the program moves on to conditional3, and so on. Only if all three conditionals failed would Block 4 be executed.
The ternary operator

The Java language provides a handy operator for doing simple if/else statement checks. Its syntax is:

(conditional) ? statementIfTrue : statementIfFalse;

If conditional evaluates to true, then statementIfTrue is executed; otherwise, statementIfFalse is executed. Compound statements are not allowed for either statement.

The ternary operator comes in handy when you know you will need to execute one statement as the result of the conditional evaluating to true, and another if it does not. Ternary operators are most often used to initialize a variable (like a return value), like so:

public int getHeight() {
  return (gender.equals("MALE")) ? (height + 2) : height;
}

The parentheses following the question mark above aren't strictly required, but they do make the code more readable.

Back to top
Loops

In addition to being able to apply conditions to your programs and see different outcomes based on various if/then scenarios, you sometimes want your code just to do the same thing over and over again until the job is done. In this section, learn about two constructs used to iterate over code or execute it more than once: for loops and while loops.
What is a loop?

A loop is a programming construct that executes repeatedly while some condition (or set of conditions) is met. For instance, you might ask a program to read all records until the end of a file, or loop over all the elements of an array, processing each one. (You'll learn about arrays in this tutorial's Java Collections section.)
for loops

The basic loop construct in the Java language is the for statement, which lets you iterate over a range of values to determine how many times to execute a loop. The abstract syntax for a for loop is:

for (initialization; loopWhileTrue; executeAtBottomOfEachLoop) {
  statementsToExecute
}

At the beginning of the loop, the initialization statement is executed (multiple initialization statements can be separated by commas). So long as loopWhileTrue (a Java conditional expression that must evaluate to either true or false) is true, the loop will be executed. At the bottom of the loop, executeAtBottomOfEachLoop is executed.
Example of a for loop

If you wanted to change a main() method to execute three times, you could use a for loop, as shown in Listing 9:
Listing 9. A for loop

public static void main(String[] args) {
  Logger l = Logger.getLogger(Person.class.getName());
  for (int aa = 0; aa < 3; aa++) {
    Person p = new Person("Joe Q Author", 42, 173, 82, "Brown", "MALE");
    l.info("Loop executing iteration# " + aa);
    l.info("Name: " + p.getName());
    l.info("Age:" + p.getAge());
    l.info("Height (cm):" + p.getHeight());
    l.info("Weight (kg):" + p.getWeight());
    l.info("Eye Color:" + p.getEyeColor());
    l.info("Gender:" + p.getGender());
  }
}

The local variable aa is initialized to zero at the beginning of the listing. This statement executes only once, when the loop is initialized. The loop then continues three times, and each time aa is incremented by one.

As you will see later, an alternate for loop syntax is available for looping over constructs that implement the Iterable interface (such as arrays and other Java utility classes). For now, just note the use of the for loop syntax in Listing 9.
while loops

The syntax for a while loop is:

while (loopWhileTrue) {
  statementsToExecute
}

As you might suspect, while loopWhileTrue evaluates to true, so the loop will execute. At the top of each iteration (that is, before any statements execute), the condition is evaluated. If true, the loop executes. So it is possible that a while loop will never execute if its conditional expression is not true at least once.

Look again at the for loop in Listing 9. For comparison, Listing 10 codes it using a while loop:
Listing 10. A while loop

public static void main(String[] args) {
  Logger l = Logger.getLogger(Person.class.getName());
  int aa = 0;
  while (aa < 3) {
    Person p = new Person("Joe Q Author", 42, 173, 82, "Brown", "MALE");
    l.info("Loop executing iteration# " + aa);
    l.info("Name: " + p.getName());
    l.info("Age:" + p.getAge());
    l.info("Height (cm):" + p.getHeight());
    l.info("Weight (kg):" + p.getWeight());
    l.info("Eye Color:" + p.getEyeColor());
    l.info("Gender:" + p.getGender());
    aa++;
  }

As you can see, a while loop requires a bit more housekeeping than a for loop. You must initialize the aa variable and also remember to increment it at the bottom of the loop.
do...while loops

If you want a loop that will always execute once and then check its conditional expression, try using a do...while loop, as shown in Listing 11:
Listing 11. A do...while loop

int aa = 0;
do {
  Person p = new Person("Joe Q Author", 42, 173, 82, "Brown", "MALE");
  l.info("Loop executing iteration# " + aa);
  l.info("Name: " + p.getName());
  l.info("Age:" + p.getAge());
  l.info("Height (cm):" + p.getHeight());
  l.info("Weight (kg):" + p.getWeight());
  l.info("Eye Color:" + p.getEyeColor());
  l.info("Gender:" + p.getGender());
  aa++;
} while (aa < 3);

The conditional expression (aa < 3) is not checked until the end of the loop.
Loop branching

There are times when you need to bail out of a loop before the conditional expression evaluates to false. This could happen if you were searching an array of Strings for a particular value, and once you found it, you didn't care about the other elements of the array. For those times when you just want to bail, the Java language provides the break statement, as shown in Listing 12:
Listing 12. A break statement

public static void main(String[] args) {
  Logger l = Logger.getLogger(Person.class.getName());
  int aa = 0;
  while (aa < 3) {
    if (aa == 1)
      break;
    Person p = new Person("Joe Q Author", 42, 173, 82, "Brown", "MALE");
    l.info("Loop executing iteration# " + aa);
    l.info("Name: " + p.getName());
    l.info("Age:" + p.getAge());
    l.info("Height (cm):" + p.getHeight());
    l.info("Weight (kg):" + p.getWeight());
    l.info("Eye Color:" + p.getEyeColor());
    l.info("Gender:" + p.getGender());
    aa++;
  }

The break statement takes you to the very next executable statement outside of the loop in which it's located.
Loop continuation

In the (simplistic) example in Listing 12, you only want to execute the loop once and bail. You can also skip a single iteration of a loop but continue executing the loop. For that, you need the continue statement, shown in Listing 13:
Listing 13. A continue statement

public static void main(String[] args) {
Logger l = Logger.getLogger(Person.class.getName());
int aa = 0;
while (aa < 3) {
  if (aa == 1)
    continue;
  else
    aa++;
  Person p = new Person("Joe Q Author", 42, 173, 82, "Brown", "MALE");
  l.info("Loop executing iteration# " + aa);
  l.info("Name: " + p.getName());
  l.info("Age:" + p.getAge());
  l.info("Height (cm):" + p.getHeight());
  l.info("Weight (kg):" + p.getWeight());
  l.info("Eye Color:" + p.getEyeColor());
  l.info("Gender:" + p.getGender());
}

In Listing 13, you skip the second iteration of a loop but continued to the third. continue comes in handy when you are, say, processing records and come across a record you definitely don't want to process. Just skip that record and move on to the next one.

Back to top
Java Collections

Most real-world applications deal with collections of things: files, variables, records from files, database result sets, and so forth. The Java language has a sophisticated Collections Framework that allows you to create and manage collections of objects of various types. This section won't teach you everything about Java Collections, but it will introduce the most commonly used collection classes and get you started with using them.
Arrays

Most programming languages include the concept of an array to hold a collection of things, and the Java language is no exception. An array is nothing more than a collection of elements of the same type.

Note: The square brackets in this section's code examples are part of the required syntax for Java Collections, not indicators of optional elements.

You can declare an array in one of two ways:

    Create it with a certain size, which is fixed for the life of the array.
    Create it with a certain set of initial values. The size of this set determines the size of the array — it will be exactly large enough to hold all of those values, and its size is fixed for the life of the array.

Declaring an array

In general, you declare an array like this:

new elementType [arraySize]

There are two ways to create an integer array of elements. This statement creates an array with space for five elements, but it is empty:

// creates an empty array of 5 elements:
int[] integers = new int[5];

This statement creates the array and initializes it all at once:

// creates an array of 5 elements with values:
int[] integers = new int[] { 1, 2, 3, 4, 5 };

The initial values go between the curly braces and are separated by commas.
Arrays the hard way

A harder way to create an array would be to create it and then code a loop to initialize it:

int[] integers = new int[5];
for (int aa = 0; aa < integers.length; aa++) {
  integers[aa] = aa;
}

This code declares the integer array of five elements. If you try to put more than five elements in the array, the Java runtime will complain and throw an exception. You'll learn about exceptions and how to handle them in Part 2.
Loading an array

To load the array, you loop through the integers from 1 through the length of the array (which you get by calling .length on the array — more about that in a minute). In this case, you stop when you hit 5.

Once the array is loaded, you can access it as before:

Logger l = Logger.getLogger("Test");
for (int aa = 0; aa < integers.length; aa++) {
  l.info("This little integer's value is: " + integers[aa]);
}

This syntax (new since JDK 5) also works:

Logger l = Logger.getLogger("Test");
for (int i : integers) {
  l.info("This little integer's value is: " + i);
}

I find the newer syntax simpler to work with, and I'll use it throughout this section.
The element index

Think of an array as a series of buckets, and into each bucket goes an element of a certain type. Access to each bucket is gained using an index:

element = arrayName [elementIndex];

To access an element, you need the reference to the array (its name) and the index where the element you want resides.
The length method

A handy method, as you've already seen, is length. It's a built-in method, so its syntax doesn't include the usual parentheses. Just type the word length and it will return — as you would expect — the size of the array.

Arrays in the Java language are zero-based. So, for some array named array, the first element in the array always resides at array[0], and the last resides at array[array.length - 1].
An array of objects

You've seen how arrays can hold primitive types, but it's worth mentioning that they can also hold objects. In that sense, the array is the Java language's most utilitarian collection.

Creating an array of java.lang.Integer objects isn't much different from creating an array of primitive types. Once again, you have two ways to do it:

// creates an empty array of 5 elements:
Integer[] integers = new Integer[5];

// creates an array of 5 elements with values:
Integer[] integers = new Integer[] { Integer.valueOf(1),
                                     Integer.valueOf(2)
                                     Integer.valueOf(3)
                                     Integer.valueOf(4)
                                     Integer.valueOf(5));

Boxing and unboxing

Every primitive type in the Java language has a JDK counterpart class, which you can see in Table 4:
Table 4. Primitives and JDK counterparts
Primitive    JDK counterpart
boolean    java.lang.Boolean
byte    java.lang.Byte
char    java.lang.Character
short    java.lang.Short
int    java.lang.Integer
long    java.lang.Long
float    java.lang.Float
double    java.lang.Double

Each JDK class provides methods to parse and convert from its internal representation to a corresponding primitive type. For example, this code converts the decimal value 238 to an Integer:

int value = 238;
Integer boxedValue = Integer.valueOf(value);

This technique is known as boxing, because you're putting the primitive into a wrapper, or box.

Similarly, to convert the Integer representation back to its int counterpart, you would unbox it, like so:

Integer boxedValue = Integer.valueOf(238);
int intValue = boxedValue.intValue();

Autoboxing and auto-unboxing

Strictly speaking, you don't need to box and unbox primitives explicitly. Instead, you could use the Java language's autoboxing and auto-unboxing features, like so:

int intValue = 238;
Integer boxedValue = intValue;
//
intValue = boxedValue;

I recommend that you avoid autoboxing and auto-unboxing, however, because it can lead to code problems. The code in the boxing and unboxing snippets is more obvious, and thus more readable, than the autoboxed code, and I believe that's worth the extra effort.
Parsing and converting boxed types

You've seen how to obtain a boxed type, but what about parsing a String you suspect has a boxed type into its proper box? The JDK wrapper classes have methods for that, too:

String characterNumeric = "238";
Integer convertedValue = Integer.parseInt(characterNumeric);

You can also convert the contents of a JDK wrapper type to a String:

Integer boxedValue = Integer.valueOf(238);
String characterNumeric = boxedValue.toString();

Note that when you use the concatenation operator in a String expression (you've already seen this in calls to Logger), the primitive type is autoboxed, and wrapper types automatically have toString() invoked on them. Pretty handy.
Lists

A List is a collection construct that is by definition an ordered collection, also known as a sequence. Because a List is ordered, you have complete control over where in the List items go. A Java List collection can only hold objects, and it defines a strict contract about how it behaves.

List is an interface, so you can't instantiate it directly. You'll work with its most commonly used implementation, ArrayList:

List<Object> listOfObjects = new ArrayList<Object>();

Note that we have assigned the ArrayList object to a variable of type List. Java programming allows you to assign a variable of one type to another so long as the variable being assigned to is a superclass or interface implemented by the variable being assigned from. We will look more at how variable assignments are affected in Part 2 in the Inheritance section.
Formal type

What's with the <Object> in the above code snip? It's called the formal type, and it tells the compiler that this List contains a collection of type Object, which means you can pretty much put whatever you like in the List.

If you wanted to tighten up the constraints on what could or could not go into the List, you'd define it differently:

List<Person> listOfPersons = new ArrayList<Person>();

Now your List can only hold Person instances.
Using Lists

Using Lists is super easy, like Java collections in general. Here are some of the things you will want to do with Lists:

    Put something in the List.
    Ask the List how big it currently is.
    Get something out of the List.

Let's try some of these out. You've already seen how to create an instance of List by instantiating its ArrayList implementation type, so you'll start from there.

To put something in a List, call the add() method:

List<Integer> listOfIntegers = new ArrayList<Integer>();
listOfIntegers.add(Integer.valueOf(238));

The add() method adds the element to the end of the List.

To ask the List how big it is, call size():

List<Integer> listOfIntegers = new ArrayList<Integer>();
listOfIntegers.add(Integer.valueOf(238));
Logger l = Logger.getLogger("Test");
l.info("Current List size: " + listOfIntegers.size());

To retrieve an item from the List, call get() and pass it the index of the item you want:

List<Integer> listOfIntegers = new ArrayList<Integer>();
listOfIntegers.add(Integer.valueOf(238));
Logger l = Logger.getLogger("Test");
l.info("Item at index 0 is: " listOfIntegers.get(0));

In a real-world application, a List would contain records, or business objects, and you would possibly want to look over them all as part of your processing. How do you do that in a generic fashion? You want to iterate over the collection, which you can do because List implements the java.lang.Iterable interface. (You'll learn about interfaces in Part 2.)
Iterable

If a collection implements java.lang.Iterable, it is called an iterable collection. That means you can start at one end and walk through the collection item-by-item until you run out of items.

You've already seen the special syntax for iterating over collections that implement the Iterable interface, in the Loops section. Here it is again:

for (objectType varName : collectionReference) {
  // Start using objectType (via varName) right away...
}

Iterating over a List

That previous example was abstract; now here's a more realistic one:

List<Integer> listOfIntegers = obtainSomehow();
Logger l = Logger.getLogger("Test");
for (Integer i : listOfIntegers) {
  l.info("Integer value is : " + i);
}

That little code snip does the same thing as this longer one:

List<Integer> listOfIntegers = obtainSomehow();
Logger l = Logger.getLogger("Test");
for (int aa = 0; aa < listOfIntegers.size(); aa++) {
  Integer I = listOfIntegers.get(aa);
  l.info("Integer value is : " + i);
}

The first snip uses shorthand syntax: there is no index variable (aa in this case) to initialize, and no call to the List's get() method.

Because List extends java.util.Collection, which implements Iterable, you can use the shorthand syntax to iterate over any List.
Sets

A Set is a collections construct that by definition contains unique elements — that is, no duplicates. Whereas a List can contain the same object hundreds of times, a Set can only contain a given instance once. A Java Set collection can only hold objects, and it defines a strict contract about how it behaves.

Because Set is an interface, you can't instantiate it directly, so I'll show you one of my favorite implementations: HashSet. HashSet is easy to use and is similar to List.

Here are some things you will want to do with a Set:

    Put something in the Set.
    Ask the Set how big it currently is.
    Get something out of the Set.

Using Sets

A Set's distinguishing attribute is that it guarantees uniqueness among its elements, but doesn't care about the order of the elements. Consider the following code:

Set<Integer> setOfIntegers = new HashSet<Integer>();
setOfIntegers.add(Integer.valueOf(10));
setOfIntegers.add(Integer.valueOf(11));
setOfIntegers.add(Integer.valueOf(10));
for (Integer i : setOfIntegers) {
  l.info("Integer value is: " + i);
}

You might expect that the Set would have three elements in it, but in fact it only has two because the Integer object that contains the value 10 will only be added once.

Keep this behavior in mind when iterating over a Set, like so:

Set<Integer> setOfIntegers = new HashSet();
setOfIntegers.add(Integer.valueOf(10));
setOfIntegers.add(Integer.valueOf(20));
setOfIntegers.add(Integer.valueOf(30));
setOfIntegers.add(Integer.valueOf(40));
setOfIntegers.add(Integer.valueOf(50));
Logger l = Logger.getLogger("Test");
for (Integer i : setOfIntegers) {
  l.info("Integer value is : " + i);
}

Chances are the objects will print out in a different order than you added them in because a Set guarantees uniqueness, not order. You'll see this for yourself if you paste the code above into the main() method of your Person class and run it.
Maps

A Map is a handy collection construct because it lets you associate one object (the key) with another (the value). As you might imagine, the key to the Map must be unique, and it's used to retrieve the value at a later time. A Java Map collection can only hold objects, and it defines a strict contract about how it behaves.

Because Map is an interface, you can't instantiate it directly, so I'll show you one of my favorite implementations: HashMap.

Here are some of the things you will want to do with Maps:

    Put something in the Map.
    Get something out of the Map.
    Get a Set of keys to the Map— for iterating over it.

Using Maps

To put something into a Map, you need to have an object that represents its key and an object that represents its value:

public Map<String, Integer> createMapOfIntegers() {
  Map<String, Integer> mapOfIntegers = new HashMap<String, Integer>();
  mapOfIntegers.put("1", Integer.valueOf(1));
  mapOfIntegers.put("2", Integer.valueOf(2));
  mapOfIntegers.put("3", Integer.valueOf(3));
  // . . .
  mapOfIntegers.put("168", Integer.valueOf(168));
}

In this example, Map contains Integers, keyed by a String, which happens to be their String representation. To retrieve a particular Integer value, you need its String representation:

mapOfIntegers = createMapOfIntegers();
Integer oneHundred68 = mapOfIntegers.get("168");

Using Set with Map

On occasion, you may find yourself with a reference to a Map, and you simply want to walk over its entire set of contents. In this case, you will need a Set of the keys to the Map:

Set<String> keys = mapOfIntegers.keySet();
Logger l = Logger.getLogger("Test");
for (String key : keys) {
  Integer value = mapOfIntegers.get(key);
  l.info("Value keyed by '" + key + "' is '" + value + "'");
}

Note that the toString() method of the Integer retrieved from the Map is automatically called when used in the Logger call. Map doesn't return a List of its keys because the Map is keyed, and each key is unique; uniqueness is the distinguishing characteristic of a Set.

Back to top
Archiving Java code

Now that you've learned a bit about writing Java applications, you may be wondering how to package them up so that other developers can use them, or how to import code from other developers into your applications. This section shows you how.
JARs

The JDK ships with a tool called JAR, which stands for Java Archive. You use this tool to create JAR files. Once you've packaged your code into a JAR file, other developers can simply drop the JAR file into their projects and configure their projects to use your code.

Creating a JAR file in Eclipse is a snap. In your workspace, right-click the com.makotogroup.intro package and select Export. You'll see the dialog shown in Figure 8. Choose Java > JAR file.
Figure 8. Export dialog box.
Eclipse's export dialog box.

When the next dialog box opens, browse to the location where you want to store your JAR file and name the file whatever you'd like. The .jar extension is the default, which I recommend using. Click Finish.

You'll see your JAR file in the location you selected. You can use the classes in it from your code if you put it in your build path in Eclipse. Doing that is a snap, too, as you'll see next.
Using third-party applications

As you grow more comfortable with writing Java applications, you will want to use more and more third-party applications to support your code. For the sake of example, let's say that you wanted to use joda-time, a JDK replacement library for doing date/time handling, manipulations, and calculations.

Let's assume you've already downloaded joda-time, which is stored in a JAR file. To use the classes, your first step is to create a lib directory in your project and drop the JAR file into it:

    Right-click the Intro root folder in Project Explorer view.
    Choose New > Folder and call the folder lib.
    Click Finish.

The new folder shows up at the same level as src. Now copy the joda-time .jar file into your new lib directory. For this example, the file is called joda-time-1.6.jar. (It's common in naming a JAR file to include the version number.)

Now all you need to do is tell Eclipse to include the classes in the joda-time-1.6.jar file into your project:

    Right-click the Intro project in your workspace, then select Properties.
    In the Properties dialog box, select the Libraries tab, as shown in Figure 9:
    Figure 9. Properties > Java Build Path
    Path to select the Properties dialog box and Libraries tab.
    Click the Add External JARs button, then browse to the project's lib directory, select the joda-time-1.6.jar file, and click OK.

Once the code (that is, the class files) in the JAR file have been processed by Eclipse, they are available to reference (import) from your Java code. Notice in Project Explorer that there is a new Folder called Referenced Libraries that contains the joda-time-1.6.jar file.

Back to top
Writing good Java code

You've got enough Java syntax under your belt to write basic Java programs, which means the first half of this tutorial is about to conclude. This final section lays out a few best practices that will help you write cleaner, more maintainable Java code.
Keep classes small

You created a few classes in this tutorial. After generating getter/setter pairs for even the small number (by the standards of a real-world Java class) of attributes, the Person class has 150 lines of code. This is a small class. It's not uncommon to see classes with 50 or 100 methods and a thousand lines of source (or more). The point to methods is to keep just the ones you need. If you need several helper methods that do essentially the same thing but take different parameters (such as the printAudit() method), that's a fine choice. Just be sure to limit the list of methods to what you need, and no more.

In general, classes represent some conceptual entity in your application, and their size should reflect only the functionality to do whatever that entity needs to do. They should stay tightly focused to do a small number of things and do them well.
Name methods carefully

A good coding pattern when it comes to method names is the intention-revealing method-names pattern. This pattern is easiest to understand with a simple example. Which of the following method names is easier to decipher at a glance?

    a()
    computeInterest()

The answer should be obvious, yet for some reason, programmers have a tendency to give methods (and variables, for that matter) small, abbreviated names. Certainly, a ridiculously long name can be inconvenient, but a name that conveys what a method does needn't be ridiculously long. Six months after you write a bunch of code, you may not remember what you meant to do with a method called a(), but it's obvious that a method called computeInterest(), well, probably computes interest.
Keep methods small

Small methods are just as preferable as small classes, and for similar reasons. One idiom I try to follow is to keep the size of a method to one page as I look at it on my screen. This makes my application classes more maintainable.

If a method grows beyond one page, I refactor it. Refactoring means changing the design of existing code without changing its results. Eclipse has a wonderful set of refactoring tools. Usually a long method contains subgroups of functionality bunched together. Take this functionality and move it to another method (naming it accordingly) and pass in parameters as needed.

Limit each method to a single job. I've found that a method doing only one thing well doesn't usually take more than about 30 lines of code.
Use comments

Please, use comments. The people who follow along behind you (or even you, yourself, six months down the road) will thank you. You may have heard the old adage Well-written code is self-documenting, so who needs comments? I'll give you two reasons why this is false:

    Most code is not well written.
    Your code probably isn't as well written as you'd like to think.

So, comment your code. Period.
Use a consistent style

Coding style is really a matter of personal preference, but I would like to offer this piece of advice: use standard Java syntax for braces:

public static void main(String[] args) {
}

Don't use this style:

public static void main(String[] args)
{
}

Or this one:

public static void main(String[] args)
  {
  }

Why? Well, it's standard, so most code you run across (as in, code you didn't write, but might be paid to maintain) will most likely be written that way. Having said that, Eclipse does allow you to define code styles and format your code any way you like. The main thing is that you pick a style and stick with it.
Use built-in logging

Before Java 1.4 introduced built-in logging, the canonical way to find out what your program was doing was to make a system call like this one:

public void someMethod() {
  // Do some stuff...
  // Now tell all about it
  System.out.println("Telling you all about it:");
  // Etc...
}

The Java language's built-in logging facility (refer back to Your first Java object) is a better alternative. I never use System.out.println() in my code, and I suggest you don't use it either.
In the footsteps of Fowler

The best book in the industry (in my opinion, and I'm not alone) is Refactoring: Improving the Design of Existing Code, by Martin Fowler et al. (see Resources). It's even fun to read. Fowler and his co-authors talk about "code smells" that beg for refactoring, and they go into great detail about the various techniques for fixing them.

In my opinion, refactoring and the ability to write test-first code are the most important skills for new programmers to learn. If everybody were good at both, it would revolutionize the industry. If you become good at both, you will ultimately produce cleaner code and more functional applications than many of your peers.

Back to top
Conclusion to Part 1

In this tutorial, you've learned about object-oriented programming, discovered Java syntax that lets you create useful objects, and familiarized yourself with an IDE that helps you control your development environment. You know how to create and run Java objects that can do a good number of things, including doing different things based on different input. You also know how to JAR up your applications for other developers to use in their programs, and you've got some basic best Java programming practices under your belt.
What's next

In the second half of this tutorial, you will begin learning about some of the more advanced constructs of Java programming, although the overall discussion will still be introductory in scope. Java programming topics covered in that tutorial include:

    Inheritance and abstraction
    Interfaces
    Nested classes
    Regular expressions
    Generics
    Enum types
    I/O
    Serialization

 

DNA News and Research

DNA, or deoxyribonucleic acid, is the hereditary material in humans and almost all other organisms. Nearly every cell in a person’s body has the same DNA. Most DNA is located in the cell nucleus (where it is called nuclear DNA), but a small amount of DNA can also be found in the mitochondria (where it is called mitochondrial DNA or mtDNA).

The information in DNA is stored as a code made up of four chemical bases: adenine (A), guanine (G), cytosine (C), and thymine (T). Human DNA consists of about 3 billion bases, and more than 99 percent of those bases are the same in all people. The order, or sequence, of these bases determines the information available for building and maintaining an organism, similar to the way in which letters of the alphabet appear in a certain order to form words and sentences.

DNA bases pair up with each other, A with T and C with G, to form units called base pairs. Each base is also attached to a sugar molecule and a phosphate molecule. Together, a base, sugar, and phosphate are called a nucleotide. Nucleotides are arranged in two long strands that form a spiral called a double helix. The structure of the double helix is somewhat like a ladder, with the base pairs forming the ladder’s rungs and the sugar and phosphate molecules forming the vertical sidepieces of the ladder.

An important property of DNA is that it can replicate, or make copies of itself. Each strand of DNA in the double helix can serve as a pattern for duplicating the sequence of bases. This is critical when cells divide because each new cell needs to have an exact copy of the DNA present in the old cell.

 New  gene theraphy may be effective for fighting fungal infections in cancer patient

Sleeping Beauty and fungal infections - not two items one would normally associate together, but for immunocompromised cancer patients they may prove to be a helpful combination. [More]

 

From Sharing Rice To Sharing Thief: APC And PDP



In Nigeria crime pays: study armed robbers, politicians and terrorists. PDP and APC are fighting over who owns more armed robbers. No need to fight, they both do. They both distribute rice to buy the dignity of the people; they both steal the people's mandate by any mean necessary and subvert it; they both pay and arm robbers and finance and protect terrorists to intimidate, kill and bomb.
Whoever does it a little more than the other is no concern of ours. Armed robbers, terrorists and politicians are the same socio-occupational class.
Think about this - what type of person hires armed robbers? Do you know any occupation and type of individual that ever hires armed robbers other than Nigeria's politicians? Do you know any armed robbers? Do you know the market where armed robbers are hired from? Do you know where guns are sold and how to procure them? If your answer to these questions is yes, then you can only be a politician.
This explains our curse as a nation, when it is the worst and most filthy scum from among us; the only of us who know where armed robbers dwell and who rent robbers and terrorists that we allow to continue to rule over us. Indeed we are living a curse.
The EFCC (Economic Financial Crimes Commission) caught the current First lady/president's wife, Patience Jonathan not once, but twice around 2006, while Jonathan was Bayelsa state governor. She was caught trying to launder over $13million stolen state funds out of the country.
The president of Nigeria is described by wikileaks as having been a well known sponsor of Niger Delta terrorists while he was deputy governor and governor of Bayelsa state. The strategic Abuja bombing upon assumption of office with the concept of 'blame the opponents for success of terror,' came as no surprise to many.
We can run through most of the politicians in Nigeria and state governors across all party lines we will see the same records. They all know the address of armed robbers and hire these people to defend and intimidate.
The worst evil the colonialist did to us in Africa was to leave us with this political demoncrazy abomination. I wonder if God can forgive them for what they have done to us - this rubbish that makes terrorist armed robbers our rulers (ruiners), they have let us waste our time with.


Alleged N1.56B Fraud: Taraba State Accountant-General Charged

 



SAN FRANCISCO, July 09, (THEWILL) - The Economic and Financial Crimes Commission Wednesday arraigned the Taraba State Accountant-General, Joel Joseph Lenbang, before Justice Donatus Nwabueze Okorowo of the Federal High Court Jalingo for defrauding Taraba State Government to the tune of N1.56 billion.
He was docked on an 8-count charge bordering on obtaining by false pretence, offences contrary to and punishable under the Advanced Fee Fraud and Other Related Offences Act, 2006.
When the charges were read to him, the accused person pleaded not guilty.
The malfeasance came to light following a petition received from a concerned Taraba State indigene, sometime in February 2014, alleging massive looting of Taraba state funds. The petition triggered investigation of the lifestyle of some of the officers mentioned in the petition and who were believed to be living above their means.
The investigation uncovered systematic withdrawal of state funds through a scheme masterminded by the Accountant-General of the State.
Withdrawals were allegedly made under the guise that such monies were used for sundry payments on behalf of ministries, departments and agencies (MDAs), as well as payment of bank commissions on turn over (COT) and Value Added Tax (VAT) which became a monthly affair.
A total sum of N1,567,226,557.081 (one billion, five hundred and sixty seven million, two hundred and twenty six thousand, five hundred and fifty seven naira, eighty one kobo) was discovered to have been looted from the state treasury between January 2012 and December 2013.
In view of the plea of the accused, prosecuting counsel, Al Qasim Ja'afar applied for a date to commence trial. Counsel to accused, Abayomi Akamode, however, informed the court that he had filed a motion for bail this morning and urged the court hear it.
But Al Qasim told the court that he was just served the motion on notice in court and would need time to peruse and respond appropriately.
Justice Okorowo adjourned the case till July 11, 2014 for hearing of the bail application and remanded the accused in prison custody.
Meanwhile, Justice Olukayode Adegbola Adeniyi of the High Court of the Federal Capital Territory, Abuja on Tuesday, July 8, 2014 convicted and sentenced the duo of Duru Cosmos and Paul Momoh of Mbakwha Cooperative Society to two years and three months imprisonment for conspiracy and criminal breach of trust.
The duo were arraigned on June 29, 2012 by the EFCC on a 2-count charge of fraudulent conversion of project funds for personal use following a petition by the Ministry of Mines and Steels Development.
The convicts who are the chairman and secretary of Mbakwha Cooperative Society respectively were said to have been awarded a grant by the Ministry under the World Bank loan to develop the solid minerals sector of the economy. The convicts allegedly converted the money to personal use, while efforts to make them refund the money proved futile.
Justice Adeniyi found the duo guilty on the two count charge preferred against them. On count one, the two accused were sentenced to three months imprisonment with an option of fine in the sum of N1, 250,000.00 (One Million, Two Hundred and Fifty Thousand naira) each; and on count two, the accused were sentenced to two years with an option of N1.250,000.00 (One Million, Two Hundred and Fifty Thousand naira) fine each. The sentences are to run consecutively.
One of the counts read:'That you Duru Cosmos and Paul Momoh being the Chairman and Secretary of Mbakwha Cooperative society on or about 9th of December,2009 at Abuja Judicial Division of the High Court of the Federal Capital Territory did Dishonestly convert to your own use the sum of N4,826,850.00 (Four Million Eight Hundred and Twenty Six Thousand, Eight Hundred and Fifty Naira only) given to you by the Federal Ministry of Mines and Steel Developments for the procurement of Atlas Copco XAS 47 Air Compressor, Jack Hammer with accessories and Diaphram Water Pump, to enhance your mining activities and thereby committed an offence punishable under Section 312 of the Penal Code Act Cap 532, Laws of the Federation of Nigeria (Abuja) 2004.'