You can write java code in Pega using activity java steps. And it's like normal java programming and there is no special/extra syntax involved. There are additional APIs available in Pega that can be utilized as well. Information about those APIs could be found in Pega Engine APIs menu.
Let us know if this helps or you need more information on this :)
1. I got a clear understanding of writing java in a function rule but I still need a assistance to write java in a activity "java" method,I tried it gives me a error.I want to call a function in the java activity method.