Skip to content

Tag: java

spannable on android for textView

I’m setting twitter data in my Android application. I want to make the font bold and italic using Spannable but it does not work, giving an error. How can I do it? Answer I want to make the font bold and ıtalic with spannable for this u will need to make o.content text as SpannableString then set it to …

Unexpected type required variable found value

For some reason this code gives compilation Error ,could anyone explain why? Answer ToFill.get(Position) returns a value where the left-hand side of the assignment must be a variable. Instead, use set(index, element) as follows: However, what you are doing is only valid if you are using arrays, for example: A…

cannot access files in appbase’s subfolder in tomcat

I have a very simple Tomcat web app. This app is deployed to ${catalina.home}/webapps/myapp. Under myapp there are two folders: 1. WEB-INF – contains a single web.xml file with bare minimal content. 2. document – contains a folder called data. My goal is to access any files under document folder. …

How to install the JDK on Ubuntu Linux

Note: This is an old question and the answers reflect the world as it was then. Modern Ubuntu distributions have OpenJDK available which can be installed with I am trying to install the Java Development Kit (JDK) on Ubuntu Linux distribution, but I am unable to install it. What are the steps to install it on …

How static nested class has this pointer

Today I was reading about static nested class and I am little confused because of below code. What I understood about static nested class is, it behaves like a static member of outer class. It can refer only static variables and can call static methods. From the above code, the error at x=0 is fine. But what …

Converting Decimal to Binary Java

I am trying to convert decimal to binary numbers from the user’s input using Java. I’m getting errors. How do I convert Decimal to Binary in Java? Answer Your binaryForm method is getting caught in an infinite recursion, you need to return if number <= 1:

Java: Using Semaphore with timer

Hello im trying to synchronize classes using semaphore.acquire() and semaphore.release(). I’m calling semaphore.release() from a class named ReadSerialPort and semaphore.acquire() from WriteSerialPort to connect a phone-center to PC. My problem is that phone-center is not always responding. I would like…