查看: 6684| 回复: 3
跳转到指定楼层
上一主题 下一主题
收起左侧

[其他] 第一次用coderpads,这东西到底怎么用啊

🔗
Sayako | 只看该作者 |倒序浏览
全局:

2016(10-12月)-CS硕士+短暂实习或全职不超过3个月 | 内推| 码农类General全职@multiple

注册一亩三分地论坛,查看更多干货!

您需要 登录 才可以下载或查看附件。没有帐号?注册账号

x
试了一下coderpad的demo,但是怎么都出错。
举例:进去之后代码是这样的:
  1. class Solution {
  2.     public static void main(String[] args) {
  3.         XXX
  4.     }
  5. }
复制代码
之后我要是想添加自己的类的话他说要define them inline,是指直接define在solution类里面吗?还是在solution下面另起一个类,因为我平时写都是在static void main函数类下面另起一个类的,如果放在solution里面的话方法岂不是都要定义成static?

上一篇:说个笑话,湾区phone screen hr说我们基本给60-70k
下一篇:ViaSat 这家公司
🔗
jh_wade 2016-11-2 03:50:13 | 只看该作者
全局:
你直接在main里面new一个solution啊。然后新new的instance调用你在solution里面写的解题函数。
. .и
我举个例子吧
  1. import java.io.*;
  2. .google  и
  3. class RemoveDup
  4. {
  5.     private String RemoveDupString(char[] input) {
  6.         if(input == null || input.length == 0) {
  7.             return null;
  8.         }.1point3acres
  9.         int end = 0;
  10.         for(int index = 0; index < input.length;
  11.                 index++) {
  12.             if(index == 0) {
  13.                 end++;
  14.             } else if(input[index] != input[index-1]) {
  15.                 input[end] = input[index];
  16.                 end++;
  17.             }
  18.         }
  19.         return new String(input, 0, end);
  20.     }-baidu 1point3acres
  21.    
  22.     public static void main (String[] args) throws java.lang.Exception
  23.     {
  24.         RemoveDup ex = new RemoveDup();
  25.         
  26.         String array = "";
  27.         System.out.println(ex.RemoveDupString(array.toCharArray()));
  28.         
  29.         array = "accvd";
  30.         System.out.println(ex.RemoveDupString(array.toCharArray()));
  31.         . check 1point3acres for more.
  32.         array = "avcs";
  33.         System.out.println(ex.RemoveDupString(array.toCharArray()));
  34.     }
  35. }
复制代码
回复

使用道具 举报

🔗
 楼主| Sayako 2016-11-2 03:51:59 | 只看该作者
全局:
jh_wade 发表于 2016-11-2 03:50
你直接在main里面new一个solution啊。然后新new的instance调用你在solution里面写的解题函数。

我举个例 ...

现在知道了 我第一次的时候把自己的类写在solution下面 不知道怎么都是报错
回复

使用道具 举报

🔗
jh_wade 2016-11-2 03:56:17 | 只看该作者
全局:
Sayako 发表于 2016-11-2 03:51
现在知道了 我第一次的时候把自己的类写在solution下面 不知道怎么都是报错
. Waral dи,
哦哦。另写一个类确实应该也可以~
你解决了就好~
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册账号
隐私提醒:
  • ☑ 禁止发布广告,拉群,贴个人联系方式:找人请去🔗同学同事飞友,拉群请去🔗拉群结伴,广告请去🔗跳蚤市场,和 🔗租房广告|找室友
  • ☑ 论坛内容在发帖 30 分钟内可以编辑,过后则不能删帖。为防止被骚扰甚至人肉,不要公开留微信等联系方式,如有需求请以论坛私信方式发送。
  • ☑ 干货版块可免费使用 🔗超级匿名:面经(美国面经、中国面经、数科面经、PM面经),抖包袱(美国、中国)和录取汇报、定位选校版
  • ☑ 查阅全站 🔗各种匿名方法

本版积分规则

>
快速回复 返回顶部 返回列表