2 lishangzcq lishangzcq 于 2014.09.11 14:22 提问

有关The operator % is undefined for the argument type(s) int, String 的问题

一个javax.speech的小程序:

import javax.speech.Central;
import javax.speech.synthesis.*;  
public class TrySpeech {
    public static void main(String[] args) {
        Synthesizer synthesizer = Central.createSynthesizer(null);
        synthesizer.allocate();
        try {
            synthesizer.speak("Hello I am a computer", null);
            synthesizer.speak("Hello I am a <EMP>computer</EMP>", null);
            synthesizer.speak("Hello I am a <PROS PITCH=" + 10% ">computer</PROS>", null); //在这行报错
        } catch (Exception e) {
            e.printStackTrace();
        }    
    }   
}

在eclipse中敲完代码后报错:The operator % is undefined for the argument type(s) int, String

查过很多资料,类似错误案例很多,但与我这个代码的情况都不相同,不知道如何解决,求大神解惑

1个回答

lishangzcq
lishangzcq   2014.09.12 08:37

将出错代码行改为:

synthesizer.speak("Hello I am a <PROS PITCH=\"10%\">computer</PROS>", null);
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!