This is a simple program I wrote called Who Am I that shows informations about the device which it is running. Which can be useful for developers and maybe advanced users.
Download:
WhoAmI.tar.bz2 – Eclipse project. It’s configured for Android platform 4 (1.6) but should work without problems in newer Android platform versions.
WhoAmI.apk – Application installation Android [...]
27 February, 2010 - 9:39 pm
Tags: caps lock, Java, programming, socket, upcase
Posted in english | No comments
Here is a simple server for those who are starting studying sockets or just needs a simple socket server example for reuse while writing your own behavior.
Features:
A client should enter a string and the server would answer the same string, with each symbol in up case, when possible.
Default port at 8080.
One client at time.
No multi [...]
22 February, 2010 - 5:16 pm
Tags: development, i18n, Java, JUnit, locale, programming, String, teste unitário, toString, unit testing
Posted in english | No comments
Today I was programming a toString method for a class widely used in a application, using the very useful String.format that provides a C’s like printf formatter.
@Override
public String toString() {
return String.format("VO[a: %.1f, b: %.1f, c: %.1f]", a, b, a+b);
}
%.1f means a float with one digit precision after the dot separator. The code [...]
Quantos zeros tem entre um e mil?
É mais fácil responder perguntas desse tipo escrevendo pequenos programas usando o suporte a programação funcional e compreensão de lista que algumas linguagens como Python oferecem.
Para contar os zeros de um número, transformamos ele em uma string e contamos quantas substrings ‘0′ ele contém. Por exemplo o 800:
str(800).count(’0′)
# 2
Para [...]
5 January, 2010 - 6:10 pm
Tags: AWT, fonts, Java, JVM, Larabie, Larabie Fonts, programming
Posted in english | Comments Off
Here’s a program that lists fonts available in your JVM. You can also set the environment variable JAVA_FONTS to specify the font directory.
import java.awt.GraphicsEnvironment;
public class ListFonts {
public static void main(String args[]){
GraphicsEnvironment e = GraphicsEnvironment.getLocalGraphicsEnvironment();
for(String font:e.getAvailableFontFamilyNames()){
System.out.println(font);
}
}
}
By using pipes you can count how many fonts you have:
java ListFonts|wc -l
On my Ubuntu machine here I got 556 because [...]
19 December, 2009 - 7:15 am
Tags: C, Java, Python, Qt, Tiled
Posted in english | 2 comments
I’m using the Tiled Map Editor for a while, I even wrote that tutorial about it. It’s a general purpose tile map editor, written in Java but now migrating to C++ with Qt, that can be easily used with my set of free pixelart tiles.
A map done with Tiled is stored in a file with [...]
14 November, 2009 - 4:27 am
Tags: Class, Douglas Adams, Field, getclass, getDeclaredField, Hack, Hacking, Java, Life, Object, Object-Oriented Programming, OOP, Reflection
Posted in english | 3 comments
Using reflection to change the accessibility of a private object field and access it at runtime.
import java.lang.reflect.Field;
class Life {
private int meaning = 42;
}
class Hack {
public static void main(String args[]){
Life life = new Life();
[...]
8 November, 2009 - 5:47 pm
Tags: Java, Jedi, joke, programming, star wars
Posted in english | No comments
A simple Java class that calculates your Jedi name based on your first, last name, mother’s maiden name and the city you grew up.
/*
Jedi first name: 1st 3 letters of last name + 1st 2 letters of first name
Jedi last name: 1st 2 letters of mother’s maiden name + 1st 3 letters of [...]
18 September, 2009 - 1:17 pm
Tags: cameraman, duke, Java, pet
Posted in english | No comments
One more Duke.
Source: cameraman_duke.svg
fontes: cct-set-2009.zip
Quando: esse sábado agora, 19 de Setembro de 2009.
Onde: na Faculdade 7 de Setembro (Rua Alm. Maximiniano da Fonseca, 1395).
Preço: Gratuito.
O CEJUG está comemorando seu sétimo aniversário com um Café com Tapioca especial e imperdível com diversos palestrantes nacionais e muitos sorteios de brindes. A programação completa e as incrições podem ser feitas atráves [...]
5 February, 2008 - 9:30 pm
Silveira, mas já tem alguma coisa tipo a sobrecarga do C++? Algo como como eu ter duas funções de mesmo nome, mas funcao(int var) e funcao(char var)?
6 February, 2008 - 2:10 am
se for sobrcarga de operador, os sonhos não se realizaram ainda,
Silveira, já que vc está dando uma estudada em java, vê se o varags pode ser usado sem um loop foreach, porque até hoje eu não sei que diabos os três pontinhos são de verdade, :/
6 February, 2008 - 7:04 am
Esdras, tem sobrecarga de método sim, você pode mudar os parâmetros, o tipo de retorno ou a exceção levantada, para um mesmo nome de método. Agora como o sombriks falou, não tem sobrecarga de operador como em Python, por exemplo.
sombriks, eu acho que eu não entendi bem a pergunta mas acho que o (int… numeros) quer dizer que ele vai receber um vetor de inteiros. Seria o mesmo que (int [] numeros).